Added style guidance and performed enforcement
This commit is contained in:
230
.editorconfig
Normal file
230
.editorconfig
Normal file
@ -0,0 +1,230 @@
|
|||||||
|
# Remove the line below if you want to inherit .editorconfig settings from higher directories
|
||||||
|
root = true
|
||||||
|
|
||||||
|
# C# files
|
||||||
|
[*.cs]
|
||||||
|
|
||||||
|
#### Core EditorConfig Options ####
|
||||||
|
|
||||||
|
# Indentation and spacing
|
||||||
|
indent_size = 4
|
||||||
|
indent_style = space
|
||||||
|
tab_width = 4
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
end_of_line = crlf
|
||||||
|
insert_final_newline = false
|
||||||
|
|
||||||
|
#### .NET Coding Conventions ####
|
||||||
|
|
||||||
|
# Organize usings
|
||||||
|
dotnet_separate_import_directive_groups = false
|
||||||
|
dotnet_sort_system_directives_first = false
|
||||||
|
file_header_template = unset
|
||||||
|
|
||||||
|
# this. and Me. preferences
|
||||||
|
dotnet_style_qualification_for_event = false:error
|
||||||
|
dotnet_style_qualification_for_field = false:error
|
||||||
|
dotnet_style_qualification_for_method = false:error
|
||||||
|
dotnet_style_qualification_for_property = false:error
|
||||||
|
|
||||||
|
# Language keywords vs BCL types preferences
|
||||||
|
dotnet_style_predefined_type_for_locals_parameters_members = true:error
|
||||||
|
dotnet_style_predefined_type_for_member_access = true:error
|
||||||
|
|
||||||
|
# Parentheses preferences
|
||||||
|
dotnet_style_parentheses_in_arithmetic_binary_operators = always_for_clarity:error
|
||||||
|
dotnet_style_parentheses_in_other_binary_operators = always_for_clarity:error
|
||||||
|
dotnet_style_parentheses_in_other_operators = never_if_unnecessary:error
|
||||||
|
dotnet_style_parentheses_in_relational_binary_operators = always_for_clarity:error
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
dotnet_style_require_accessibility_modifiers = for_non_interface_members
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
dotnet_style_coalesce_expression = true:error
|
||||||
|
dotnet_style_collection_initializer = true:error
|
||||||
|
dotnet_style_explicit_tuple_names = true:error
|
||||||
|
dotnet_style_namespace_match_folder = true
|
||||||
|
dotnet_style_null_propagation = true:error
|
||||||
|
dotnet_style_object_initializer = true:error
|
||||||
|
dotnet_style_operator_placement_when_wrapping = beginning_of_line
|
||||||
|
dotnet_style_prefer_auto_properties = true:error
|
||||||
|
dotnet_style_prefer_compound_assignment = true:error
|
||||||
|
dotnet_style_prefer_conditional_expression_over_assignment = true:error
|
||||||
|
dotnet_style_prefer_conditional_expression_over_return = true:error
|
||||||
|
dotnet_style_prefer_foreach_explicit_cast_in_source = when_strongly_typed
|
||||||
|
dotnet_style_prefer_inferred_anonymous_type_member_names = true:error
|
||||||
|
dotnet_style_prefer_inferred_tuple_names = true:error
|
||||||
|
dotnet_style_prefer_is_null_check_over_reference_equality_method = true:error
|
||||||
|
dotnet_style_prefer_simplified_boolean_expressions = true:error
|
||||||
|
dotnet_style_prefer_simplified_interpolation = true
|
||||||
|
|
||||||
|
# Field preferences
|
||||||
|
dotnet_style_readonly_field = true:error
|
||||||
|
|
||||||
|
# Parameter preferences
|
||||||
|
dotnet_code_quality_unused_parameters = all:error
|
||||||
|
|
||||||
|
# Suppression preferences
|
||||||
|
dotnet_remove_unnecessary_suppression_exclusions = none
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
dotnet_style_allow_multiple_blank_lines_experimental = false:error
|
||||||
|
dotnet_style_allow_statement_immediately_after_block_experimental = false:error
|
||||||
|
|
||||||
|
#### C# Coding Conventions ####
|
||||||
|
|
||||||
|
# var preferences
|
||||||
|
csharp_style_var_elsewhere = false:suggestion
|
||||||
|
csharp_style_var_for_built_in_types = false:error
|
||||||
|
csharp_style_var_when_type_is_apparent = false:error
|
||||||
|
|
||||||
|
# Expression-bodied members
|
||||||
|
csharp_style_expression_bodied_accessors = true:error
|
||||||
|
csharp_style_expression_bodied_constructors = false:error
|
||||||
|
csharp_style_expression_bodied_indexers = true:error
|
||||||
|
csharp_style_expression_bodied_lambdas = true:error
|
||||||
|
csharp_style_expression_bodied_local_functions = true:error
|
||||||
|
csharp_style_expression_bodied_methods = false:error
|
||||||
|
csharp_style_expression_bodied_operators = when_on_single_line:error
|
||||||
|
csharp_style_expression_bodied_properties = true:error
|
||||||
|
|
||||||
|
# Pattern matching preferences
|
||||||
|
csharp_style_pattern_matching_over_as_with_null_check = true:error
|
||||||
|
csharp_style_pattern_matching_over_is_with_cast_check = true:error
|
||||||
|
csharp_style_prefer_extended_property_pattern = true
|
||||||
|
csharp_style_prefer_not_pattern = true:error
|
||||||
|
csharp_style_prefer_pattern_matching = false:error
|
||||||
|
csharp_style_prefer_switch_expression = true:error
|
||||||
|
|
||||||
|
# Null-checking preferences
|
||||||
|
csharp_style_conditional_delegate_call = true:error
|
||||||
|
|
||||||
|
# Modifier preferences
|
||||||
|
csharp_prefer_static_local_function = true:error
|
||||||
|
csharp_preferred_modifier_order = public,private,protected,internal,file,static,extern,new,virtual,abstract,sealed,override,readonly,unsafe,required,volatile,async
|
||||||
|
csharp_style_prefer_readonly_struct = true:error
|
||||||
|
csharp_style_prefer_readonly_struct_member = true
|
||||||
|
|
||||||
|
# Code-block preferences
|
||||||
|
csharp_prefer_braces = when_multiline:error
|
||||||
|
csharp_prefer_simple_using_statement = true:error
|
||||||
|
csharp_style_namespace_declarations = block_scoped:error
|
||||||
|
csharp_style_prefer_method_group_conversion = true:error
|
||||||
|
csharp_style_prefer_primary_constructors = true
|
||||||
|
csharp_style_prefer_top_level_statements = false:error
|
||||||
|
|
||||||
|
# Expression-level preferences
|
||||||
|
csharp_prefer_simple_default_expression = true:error
|
||||||
|
csharp_style_deconstructed_variable_declaration = true:error
|
||||||
|
csharp_style_implicit_object_creation_when_type_is_apparent = true:error
|
||||||
|
csharp_style_inlined_variable_declaration = true:error
|
||||||
|
csharp_style_prefer_index_operator = false:error
|
||||||
|
csharp_style_prefer_local_over_anonymous_function = true:error
|
||||||
|
csharp_style_prefer_null_check_over_type_check = true:error
|
||||||
|
csharp_style_prefer_range_operator = true:error
|
||||||
|
csharp_style_prefer_tuple_swap = true
|
||||||
|
csharp_style_prefer_utf8_string_literals = true
|
||||||
|
csharp_style_throw_expression = true:error
|
||||||
|
csharp_style_unused_value_assignment_preference = unused_local_variable:error
|
||||||
|
csharp_style_unused_value_expression_statement_preference = unused_local_variable:error
|
||||||
|
|
||||||
|
# 'using' directive preferences
|
||||||
|
csharp_using_directive_placement = outside_namespace:error
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
csharp_style_allow_blank_line_after_colon_in_constructor_initializer_experimental = false:error
|
||||||
|
csharp_style_allow_blank_line_after_token_in_arrow_expression_clause_experimental = false:error
|
||||||
|
csharp_style_allow_blank_line_after_token_in_conditional_expression_experimental = false:error
|
||||||
|
csharp_style_allow_blank_lines_between_consecutive_braces_experimental = false:error
|
||||||
|
csharp_style_allow_embedded_statements_on_same_line_experimental = false:error
|
||||||
|
|
||||||
|
#### C# Formatting Rules ####
|
||||||
|
|
||||||
|
# New line preferences
|
||||||
|
csharp_new_line_before_catch = true
|
||||||
|
csharp_new_line_before_else = true
|
||||||
|
csharp_new_line_before_finally = true
|
||||||
|
csharp_new_line_before_members_in_anonymous_types = true
|
||||||
|
csharp_new_line_before_members_in_object_initializers = true
|
||||||
|
csharp_new_line_before_open_brace = all
|
||||||
|
csharp_new_line_between_query_expression_clauses = true
|
||||||
|
|
||||||
|
# Indentation preferences
|
||||||
|
csharp_indent_block_contents = true
|
||||||
|
csharp_indent_braces = false
|
||||||
|
csharp_indent_case_contents = true
|
||||||
|
csharp_indent_case_contents_when_block = true
|
||||||
|
csharp_indent_labels = one_less_than_current
|
||||||
|
csharp_indent_switch_labels = true
|
||||||
|
|
||||||
|
# Space preferences
|
||||||
|
csharp_space_after_cast = true
|
||||||
|
csharp_space_after_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_after_comma = true
|
||||||
|
csharp_space_after_dot = false
|
||||||
|
csharp_space_after_keywords_in_control_flow_statements = true
|
||||||
|
csharp_space_after_semicolon_in_for_statement = true
|
||||||
|
csharp_space_around_binary_operators = before_and_after
|
||||||
|
csharp_space_around_declaration_statements = false
|
||||||
|
csharp_space_before_colon_in_inheritance_clause = true
|
||||||
|
csharp_space_before_comma = false
|
||||||
|
csharp_space_before_dot = false
|
||||||
|
csharp_space_before_open_square_brackets = false
|
||||||
|
csharp_space_before_semicolon_in_for_statement = false
|
||||||
|
csharp_space_between_empty_square_brackets = false
|
||||||
|
csharp_space_between_method_call_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_call_name_and_opening_parenthesis = false
|
||||||
|
csharp_space_between_method_call_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_empty_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_method_declaration_name_and_open_parenthesis = false
|
||||||
|
csharp_space_between_method_declaration_parameter_list_parentheses = false
|
||||||
|
csharp_space_between_parentheses = false
|
||||||
|
csharp_space_between_square_brackets = false
|
||||||
|
|
||||||
|
# Wrapping preferences
|
||||||
|
csharp_preserve_single_line_blocks = true
|
||||||
|
csharp_preserve_single_line_statements = true
|
||||||
|
|
||||||
|
#### Naming styles ####
|
||||||
|
|
||||||
|
# Naming rules
|
||||||
|
|
||||||
|
dotnet_naming_rule.interface_should_be_begins_with_i.severity = error
|
||||||
|
dotnet_naming_rule.interface_should_be_begins_with_i.symbols = interface
|
||||||
|
dotnet_naming_rule.interface_should_be_begins_with_i.style = begins_with_i
|
||||||
|
|
||||||
|
dotnet_naming_rule.types_should_be_pascal_case.severity = error
|
||||||
|
dotnet_naming_rule.types_should_be_pascal_case.symbols = types
|
||||||
|
dotnet_naming_rule.types_should_be_pascal_case.style = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascal_case.severity = error
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascal_case.symbols = non_field_members
|
||||||
|
dotnet_naming_rule.non_field_members_should_be_pascal_case.style = pascal_case
|
||||||
|
|
||||||
|
# Symbol specifications
|
||||||
|
|
||||||
|
dotnet_naming_symbols.interface.applicable_kinds = interface
|
||||||
|
dotnet_naming_symbols.interface.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.interface.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.types.applicable_kinds = class, struct, interface, enum
|
||||||
|
dotnet_naming_symbols.types.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.types.required_modifiers =
|
||||||
|
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_kinds = property, event, method
|
||||||
|
dotnet_naming_symbols.non_field_members.applicable_accessibilities = public, internal, private, protected, protected_internal, private_protected
|
||||||
|
dotnet_naming_symbols.non_field_members.required_modifiers =
|
||||||
|
|
||||||
|
# Naming styles
|
||||||
|
|
||||||
|
dotnet_naming_style.pascal_case.required_prefix =
|
||||||
|
dotnet_naming_style.pascal_case.required_suffix =
|
||||||
|
dotnet_naming_style.pascal_case.word_separator =
|
||||||
|
dotnet_naming_style.pascal_case.capitalization = pascal_case
|
||||||
|
|
||||||
|
dotnet_naming_style.begins_with_i.required_prefix = I
|
||||||
|
dotnet_naming_style.begins_with_i.required_suffix =
|
||||||
|
dotnet_naming_style.begins_with_i.word_separator =
|
||||||
|
dotnet_naming_style.begins_with_i.capitalization = pascal_case
|
||||||
@ -5,6 +5,11 @@ VisualStudioVersion = 17.7.34003.232
|
|||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{DE0790AC-036E-402C-BB2D-6FF54543B851}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{DE0790AC-036E-402C-BB2D-6FF54543B851}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{CA855B91-1761-4B48-B830-D9431F7CA6DF}"
|
||||||
|
ProjectSection(SolutionItems) = preProject
|
||||||
|
.editorconfig = .editorconfig
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace IO.Swagger.Attributes
|
|||||||
// Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/
|
// Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/
|
||||||
if (context.ActionDescriptor is ControllerActionDescriptor descriptor)
|
if (context.ActionDescriptor is ControllerActionDescriptor descriptor)
|
||||||
{
|
{
|
||||||
foreach (var parameter in descriptor.MethodInfo.GetParameters())
|
foreach (ParameterInfo parameter in descriptor.MethodInfo.GetParameters())
|
||||||
{
|
{
|
||||||
object args = null;
|
object args = null;
|
||||||
if (context.ActionArguments.ContainsKey(parameter.Name))
|
if (context.ActionArguments.ContainsKey(parameter.Name))
|
||||||
@ -41,13 +41,13 @@ namespace IO.Swagger.Attributes
|
|||||||
|
|
||||||
private static void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState)
|
private static void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState)
|
||||||
{
|
{
|
||||||
foreach (var attributeData in parameter.CustomAttributes)
|
foreach (CustomAttributeData attributeData in parameter.CustomAttributes)
|
||||||
{
|
{
|
||||||
var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType);
|
System.Attribute attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType);
|
||||||
|
|
||||||
if (attributeInstance is ValidationAttribute validationAttribute)
|
if (attributeInstance is ValidationAttribute validationAttribute)
|
||||||
{
|
{
|
||||||
var isValid = validationAttribute.IsValid(args);
|
bool isValid = validationAttribute.IsValid(args);
|
||||||
if (!isValid)
|
if (!isValid)
|
||||||
{
|
{
|
||||||
modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name));
|
modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name));
|
||||||
|
|||||||
@ -62,10 +62,10 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(UserDto), 200)]
|
[ProducesResponseType(typeof(UserDto), 200)]
|
||||||
public virtual async Task<IActionResult> GetUserDetails()
|
public virtual async Task<IActionResult> GetUserDetails()
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
var user = await repository.RetrieveUser(userId);
|
Models.db.User user = await repository.RetrieveUser(userId);
|
||||||
return Ok(mapper.Map<UserDto>(user));
|
return Ok(mapper.Map<UserDto>(user));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ namespace IO.Swagger.Controllers
|
|||||||
{
|
{
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||||
var user = await repository.LoginUser(body);
|
Models.db.User user = await repository.LoginUser(body);
|
||||||
return user == null ? Unauthorized() : Ok(new TokenDto { Token = jwt.GenerateJwt(user.Id) });
|
return user == null ? Unauthorized() : Ok(new TokenDto { Token = jwt.GenerateJwt(user.Id) });
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace IO.Swagger.Controllers
|
|||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||||
|
|
||||||
var user = await repository.RegisterUser(body);
|
Models.db.User user = await repository.RegisterUser(body);
|
||||||
return user == null ? StatusCode(409) : Ok(new TokenDto { Token = jwt.GenerateJwt(user.Id) });
|
return user == null ? StatusCode(409) : Ok(new TokenDto { Token = jwt.GenerateJwt(user.Id) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -118,14 +118,14 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(IEnumerable<string>), 400)]
|
[ProducesResponseType(typeof(IEnumerable<string>), 400)]
|
||||||
public virtual async Task<IActionResult> CreateCurrency([FromBody] CurrencyCreateBody body)
|
public virtual async Task<IActionResult> CreateCurrency([FromBody] CurrencyCreateBody body)
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||||
|
|
||||||
var createdCurr = await repo.CreateCurrency(body, userId);
|
bool createdCurr = await repo.CreateCurrency(body, userId);
|
||||||
return createdCurr ? StatusCode(201) : StatusCode(422);
|
return createdCurr ? StatusCode(201) : StatusCode(422);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,13 +145,13 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(IEnumerable<string>), 400)]
|
[ProducesResponseType(typeof(IEnumerable<string>), 400)]
|
||||||
public virtual async Task<IActionResult> MintCurrency([FromBody] CurrencyMintBody body)
|
public virtual async Task<IActionResult> MintCurrency([FromBody] CurrencyMintBody body)
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||||
|
|
||||||
var minted = await repo.MintCurrency(body, userId);
|
bool minted = await repo.MintCurrency(body, userId);
|
||||||
return minted ? Ok() : StatusCode(409);
|
return minted ? Ok() : StatusCode(409);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,18 +168,19 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(IEnumerable<CurrencyInfoDto>), 200)]
|
[ProducesResponseType(typeof(IEnumerable<CurrencyInfoDto>), 200)]
|
||||||
public virtual async Task<IActionResult> GetAllCurrencies()
|
public virtual async Task<IActionResult> GetAllCurrencies()
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var rawCurrencies = await repo.GetAllCurrencies();
|
List<Models.db.Currency> rawCurrencies = await repo.GetAllCurrencies();
|
||||||
var res = new List<CurrencyInfoDto>();
|
List<CurrencyInfoDto> res = new();
|
||||||
foreach (var raw in rawCurrencies)
|
foreach (Models.db.Currency raw in rawCurrencies)
|
||||||
{
|
{
|
||||||
var c = mapper.Map<CurrencyInfoDto>(raw);
|
CurrencyInfoDto c = mapper.Map<CurrencyInfoDto>(raw);
|
||||||
c.IsOwner = raw.UserId == userId;
|
c.IsOwner = raw.UserId == userId;
|
||||||
res.Add(c);
|
res.Add(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -49,8 +49,6 @@ namespace IO.Swagger.Controllers
|
|||||||
this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
|
this.mapper = mapper ?? throw new ArgumentNullException(nameof(mapper));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get user's wallet balances
|
/// Get user's wallet balances
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -64,12 +62,12 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(IEnumerable<WalletBalanceDto>), 200)]
|
[ProducesResponseType(typeof(IEnumerable<WalletBalanceDto>), 200)]
|
||||||
public virtual async Task<IActionResult> GetUserBalances()
|
public virtual async Task<IActionResult> GetUserBalances()
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var balances = await transactionRepository.GetBalancesForUser(userId);
|
List<Tuple<Models.db.Currency, float>> balances = await transactionRepository.GetBalancesForUser(userId);
|
||||||
var res = balances.Select(t => new WalletBalanceDto
|
IEnumerable<WalletBalanceDto> res = balances.Select(t => new WalletBalanceDto
|
||||||
{
|
{
|
||||||
Currency = mapper.Map<CurrencyDto>(t.Item1),
|
Currency = mapper.Map<CurrencyDto>(t.Item1),
|
||||||
Balance = t.Item2
|
Balance = t.Item2
|
||||||
@ -90,11 +88,11 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(IEnumerable<TransactionDto>), 200)]
|
[ProducesResponseType(typeof(IEnumerable<TransactionDto>), 200)]
|
||||||
public virtual async Task<IActionResult> GetUserTransactions()
|
public virtual async Task<IActionResult> GetUserTransactions()
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
|
|
||||||
var transactions = await transactionRepository.GetTransactionsForUser(userId);
|
List<Models.db.Transaction> transactions = await transactionRepository.GetTransactionsForUser(userId);
|
||||||
return Ok(transactions.Select(mapper.Map<TransactionDto>));
|
return Ok(transactions.Select(mapper.Map<TransactionDto>));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,14 +138,14 @@ namespace IO.Swagger.Controllers
|
|||||||
[ProducesResponseType(typeof(TransactionReturnCode), 409)]
|
[ProducesResponseType(typeof(TransactionReturnCode), 409)]
|
||||||
public virtual async Task<IActionResult> TransferPhysicalCurrency([FromBody] WalletTransferPhysicalBody body)
|
public virtual async Task<IActionResult> TransferPhysicalCurrency([FromBody] WalletTransferPhysicalBody body)
|
||||||
{
|
{
|
||||||
var userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
string userIdString = HttpContext.User.Claims.First(c => c.Type == ClaimTypes.NameIdentifier).Value;
|
||||||
if (!int.TryParse(userIdString, out int userId))
|
if (!int.TryParse(userIdString, out int userId))
|
||||||
return Unauthorized();
|
return Unauthorized();
|
||||||
if (!ModelState.IsValid)
|
if (!ModelState.IsValid)
|
||||||
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
return BadRequest(ModelState.Values.SelectMany(v => v.Errors.Select(e => e.ErrorMessage)));
|
||||||
|
|
||||||
var transactionResult = await transactionRepository.TransferPhysical(body, userId);
|
TransactionReturnCode transactionResult = await transactionRepository.TransferPhysical(body, userId);
|
||||||
return transactionResult == TransactionReturnCode.Success ? Ok() : StatusCode(409, (int)transactionResult);
|
return transactionResult == TransactionReturnCode.Success ? Ok() : StatusCode(409, (int) transactionResult);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,16 +32,16 @@ namespace IO.Swagger.Filters
|
|||||||
/// <param name="context">FilterContext</param>
|
/// <param name="context">FilterContext</param>
|
||||||
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context)
|
||||||
{
|
{
|
||||||
swaggerDoc.Servers.Add(new OpenApiServer() { Url = this.BasePath });
|
swaggerDoc.Servers.Add(new OpenApiServer() { Url = BasePath });
|
||||||
|
|
||||||
var pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(this.BasePath)).ToList();
|
System.Collections.Generic.List<System.Collections.Generic.KeyValuePair<string, OpenApiPathItem>> pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(BasePath)).ToList();
|
||||||
|
|
||||||
foreach (var path in pathsToModify)
|
foreach (System.Collections.Generic.KeyValuePair<string, OpenApiPathItem> path in pathsToModify)
|
||||||
{
|
{
|
||||||
if (path.Key.StartsWith(this.BasePath))
|
if (path.Key.StartsWith(BasePath))
|
||||||
{
|
{
|
||||||
string newKey = Regex.Replace(path.Key, $"^{this.BasePath}", string.Empty);
|
string newKey = Regex.Replace(path.Key, $"^{BasePath}", string.Empty);
|
||||||
swaggerDoc.Paths.Remove(path.Key);
|
bool unused = swaggerDoc.Paths.Remove(path.Key);
|
||||||
swaggerDoc.Paths.Add(newKey, path.Value);
|
swaggerDoc.Paths.Add(newKey, path.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,29 +18,29 @@ namespace IO.Swagger.Filters
|
|||||||
/// <param name="context">OperationFilterContext</param>
|
/// <param name="context">OperationFilterContext</param>
|
||||||
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
public void Apply(OpenApiOperation operation, OperationFilterContext context)
|
||||||
{
|
{
|
||||||
var pars = context.ApiDescription.ParameterDescriptions;
|
System.Collections.Generic.IList<Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterDescription> pars = context.ApiDescription.ParameterDescriptions;
|
||||||
|
|
||||||
foreach (var par in pars)
|
foreach (Microsoft.AspNetCore.Mvc.ApiExplorer.ApiParameterDescription par in pars)
|
||||||
{
|
{
|
||||||
var swaggerParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name);
|
OpenApiParameter swaggerParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name);
|
||||||
|
|
||||||
var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes;
|
System.Collections.Generic.IEnumerable<System.Reflection.CustomAttributeData> attributes = ((ControllerParameterDescriptor) par.ParameterDescriptor).ParameterInfo.CustomAttributes;
|
||||||
|
|
||||||
if (attributes != null && attributes.Count() > 0 && swaggerParam != null)
|
if (attributes != null && attributes.Any() && swaggerParam != null)
|
||||||
{
|
{
|
||||||
// Required - [Required]
|
// Required - [Required]
|
||||||
var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute));
|
System.Reflection.CustomAttributeData requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute));
|
||||||
if (requiredAttr != null)
|
if (requiredAttr != null)
|
||||||
{
|
{
|
||||||
swaggerParam.Required = true;
|
swaggerParam.Required = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Regex Pattern [RegularExpression]
|
// Regex Pattern [RegularExpression]
|
||||||
var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute));
|
System.Reflection.CustomAttributeData regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute));
|
||||||
if (regexAttr != null)
|
if (regexAttr != null)
|
||||||
{
|
{
|
||||||
string regex = (string)regexAttr.ConstructorArguments[0].Value;
|
string regex = (string) regexAttr.ConstructorArguments[0].Value;
|
||||||
if (swaggerParam is OpenApiParameter)
|
if (swaggerParam is not null)
|
||||||
{
|
{
|
||||||
swaggerParam.Schema.Pattern = regex;
|
swaggerParam.Schema.Pattern = regex;
|
||||||
}
|
}
|
||||||
@ -48,42 +48,43 @@ namespace IO.Swagger.Filters
|
|||||||
|
|
||||||
// String Length [StringLength]
|
// String Length [StringLength]
|
||||||
int? minLenght = null, maxLength = null;
|
int? minLenght = null, maxLength = null;
|
||||||
var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute));
|
System.Reflection.CustomAttributeData stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute));
|
||||||
if (stringLengthAttr != null)
|
if (stringLengthAttr != null)
|
||||||
{
|
{
|
||||||
if (stringLengthAttr.NamedArguments.Count == 1)
|
if (stringLengthAttr.NamedArguments.Count == 1)
|
||||||
{
|
{
|
||||||
minLenght = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value;
|
minLenght = (int) stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value;
|
||||||
}
|
}
|
||||||
maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value;
|
|
||||||
|
maxLength = (int) stringLengthAttr.ConstructorArguments[0].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute));
|
System.Reflection.CustomAttributeData minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute));
|
||||||
if (minLengthAttr != null)
|
if (minLengthAttr != null)
|
||||||
{
|
{
|
||||||
minLenght = (int)minLengthAttr.ConstructorArguments[0].Value;
|
minLenght = (int) minLengthAttr.ConstructorArguments[0].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute));
|
System.Reflection.CustomAttributeData maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute));
|
||||||
if (maxLengthAttr != null)
|
if (maxLengthAttr != null)
|
||||||
{
|
{
|
||||||
maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value;
|
maxLength = (int) maxLengthAttr.ConstructorArguments[0].Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (swaggerParam is OpenApiParameter)
|
if (swaggerParam is not null)
|
||||||
{
|
{
|
||||||
swaggerParam.Schema.MinLength = minLenght;
|
swaggerParam.Schema.MinLength = minLenght;
|
||||||
swaggerParam.Schema.MaxLength = maxLength;
|
swaggerParam.Schema.MaxLength = maxLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Range [Range]
|
// Range [Range]
|
||||||
var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute));
|
System.Reflection.CustomAttributeData rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute));
|
||||||
if (rangeAttr != null)
|
if (rangeAttr != null)
|
||||||
{
|
{
|
||||||
int rangeMin = (int)rangeAttr.ConstructorArguments[0].Value;
|
int rangeMin = (int) rangeAttr.ConstructorArguments[0].Value;
|
||||||
int rangeMax = (int)rangeAttr.ConstructorArguments[1].Value;
|
int rangeMax = (int) rangeAttr.ConstructorArguments[1].Value;
|
||||||
|
|
||||||
if (swaggerParam is OpenApiParameter)
|
if (swaggerParam is not null)
|
||||||
{
|
{
|
||||||
swaggerParam.Schema.Minimum = rangeMin;
|
swaggerParam.Schema.Minimum = rangeMin;
|
||||||
swaggerParam.Schema.Maximum = rangeMax;
|
swaggerParam.Schema.Maximum = rangeMax;
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace IO.Swagger.Migrations
|
namespace IO.Swagger.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -10,7 +8,7 @@ namespace IO.Swagger.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
var unused = migrationBuilder.CreateTable(
|
||||||
name: "Users",
|
name: "Users",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
@ -23,16 +21,13 @@ namespace IO.Swagger.Migrations
|
|||||||
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
PasswordHash = table.Column<string>(type: "nvarchar(max)", nullable: true),
|
||||||
Salt = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
Salt = table.Column<string>(type: "nvarchar(max)", nullable: true)
|
||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table => table.PrimaryKey("PK_Users", x => x.Id));
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Users", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.DropTableOperation> unused = migrationBuilder.DropTable(
|
||||||
name: "Users");
|
name: "Users");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace IO.Swagger.Migrations
|
namespace IO.Swagger.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -10,11 +8,11 @@ namespace IO.Swagger.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropColumn(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.DropColumnOperation> unused2 = migrationBuilder.DropColumn(
|
||||||
name: "Username",
|
name: "Username",
|
||||||
table: "Users");
|
table: "Users");
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.AlterOperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AlterColumnOperation> unused1 = migrationBuilder.AlterColumn<string>(
|
||||||
name: "LastName",
|
name: "LastName",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
type: "nvarchar(32)",
|
type: "nvarchar(32)",
|
||||||
@ -24,7 +22,7 @@ namespace IO.Swagger.Migrations
|
|||||||
oldType: "nvarchar(max)",
|
oldType: "nvarchar(max)",
|
||||||
oldNullable: true);
|
oldNullable: true);
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.AlterOperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AlterColumnOperation> unused = migrationBuilder.AlterColumn<string>(
|
||||||
name: "FirstName",
|
name: "FirstName",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
type: "nvarchar(32)",
|
type: "nvarchar(32)",
|
||||||
@ -38,7 +36,7 @@ namespace IO.Swagger.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.AlterColumn<string>(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.AlterOperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AlterColumnOperation> unused2 = migrationBuilder.AlterColumn<string>(
|
||||||
name: "LastName",
|
name: "LastName",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
type: "nvarchar(max)",
|
type: "nvarchar(max)",
|
||||||
@ -48,7 +46,7 @@ namespace IO.Swagger.Migrations
|
|||||||
oldMaxLength: 32,
|
oldMaxLength: 32,
|
||||||
oldNullable: true);
|
oldNullable: true);
|
||||||
|
|
||||||
migrationBuilder.AlterColumn<string>(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.AlterOperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AlterColumnOperation> unused1 = migrationBuilder.AlterColumn<string>(
|
||||||
name: "FirstName",
|
name: "FirstName",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
type: "nvarchar(max)",
|
type: "nvarchar(max)",
|
||||||
@ -58,7 +56,7 @@ namespace IO.Swagger.Migrations
|
|||||||
oldMaxLength: 32,
|
oldMaxLength: 32,
|
||||||
oldNullable: true);
|
oldNullable: true);
|
||||||
|
|
||||||
migrationBuilder.AddColumn<string>(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddColumnOperation> unused = migrationBuilder.AddColumn<string>(
|
||||||
name: "Username",
|
name: "Username",
|
||||||
table: "Users",
|
table: "Users",
|
||||||
type: "nvarchar(max)",
|
type: "nvarchar(max)",
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace IO.Swagger.Migrations
|
namespace IO.Swagger.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -11,7 +9,7 @@ namespace IO.Swagger.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
var unused11 = migrationBuilder.CreateTable(
|
||||||
name: "Currencies",
|
name: "Currencies",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
@ -23,15 +21,15 @@ namespace IO.Swagger.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Currencies", x => x.CurrencyId);
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddPrimaryKeyOperation> unused10 = table.PrimaryKey("PK_Currencies", x => x.CurrencyId);
|
||||||
table.ForeignKey(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> unused9 = table.ForeignKey(
|
||||||
name: "FK_Currencies_Users_UserId",
|
name: "FK_Currencies_Users_UserId",
|
||||||
column: x => x.UserId,
|
column: x => x.UserId,
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateTable(
|
var unused8 = migrationBuilder.CreateTable(
|
||||||
name: "Transactions",
|
name: "Transactions",
|
||||||
columns: table => new
|
columns: table => new
|
||||||
{
|
{
|
||||||
@ -46,40 +44,40 @@ namespace IO.Swagger.Migrations
|
|||||||
},
|
},
|
||||||
constraints: table =>
|
constraints: table =>
|
||||||
{
|
{
|
||||||
table.PrimaryKey("PK_Transactions", x => x.TransactionId);
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddPrimaryKeyOperation> unused7 = table.PrimaryKey("PK_Transactions", x => x.TransactionId);
|
||||||
table.ForeignKey(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> unused6 = table.ForeignKey(
|
||||||
name: "FK_Transactions_Currencies_CurrencyId",
|
name: "FK_Transactions_Currencies_CurrencyId",
|
||||||
column: x => x.CurrencyId,
|
column: x => x.CurrencyId,
|
||||||
principalTable: "Currencies",
|
principalTable: "Currencies",
|
||||||
principalColumn: "CurrencyId");
|
principalColumn: "CurrencyId");
|
||||||
table.ForeignKey(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> unused5 = table.ForeignKey(
|
||||||
name: "FK_Transactions_Users_FromUserId",
|
name: "FK_Transactions_Users_FromUserId",
|
||||||
column: x => x.FromUserId,
|
column: x => x.FromUserId,
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
table.ForeignKey(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.AddForeignKeyOperation> unused4 = table.ForeignKey(
|
||||||
name: "FK_Transactions_Users_ToUserId",
|
name: "FK_Transactions_Users_ToUserId",
|
||||||
column: x => x.ToUserId,
|
column: x => x.ToUserId,
|
||||||
principalTable: "Users",
|
principalTable: "Users",
|
||||||
principalColumn: "Id");
|
principalColumn: "Id");
|
||||||
});
|
});
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.CreateIndexOperation> unused3 = migrationBuilder.CreateIndex(
|
||||||
name: "IX_Currencies_UserId",
|
name: "IX_Currencies_UserId",
|
||||||
table: "Currencies",
|
table: "Currencies",
|
||||||
column: "UserId");
|
column: "UserId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.CreateIndexOperation> unused2 = migrationBuilder.CreateIndex(
|
||||||
name: "IX_Transactions_CurrencyId",
|
name: "IX_Transactions_CurrencyId",
|
||||||
table: "Transactions",
|
table: "Transactions",
|
||||||
column: "CurrencyId");
|
column: "CurrencyId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.CreateIndexOperation> unused1 = migrationBuilder.CreateIndex(
|
||||||
name: "IX_Transactions_FromUserId",
|
name: "IX_Transactions_FromUserId",
|
||||||
table: "Transactions",
|
table: "Transactions",
|
||||||
column: "FromUserId");
|
column: "FromUserId");
|
||||||
|
|
||||||
migrationBuilder.CreateIndex(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.CreateIndexOperation> unused = migrationBuilder.CreateIndex(
|
||||||
name: "IX_Transactions_ToUserId",
|
name: "IX_Transactions_ToUserId",
|
||||||
table: "Transactions",
|
table: "Transactions",
|
||||||
column: "ToUserId");
|
column: "ToUserId");
|
||||||
@ -88,10 +86,10 @@ namespace IO.Swagger.Migrations
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.DropTableOperation> unused1 = migrationBuilder.DropTable(
|
||||||
name: "Transactions");
|
name: "Transactions");
|
||||||
|
|
||||||
migrationBuilder.DropTable(
|
Microsoft.EntityFrameworkCore.Migrations.Operations.Builders.OperationBuilder<Microsoft.EntityFrameworkCore.Migrations.Operations.DropTableOperation> unused = migrationBuilder.DropTable(
|
||||||
name: "Currencies");
|
name: "Currencies");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,11 +40,11 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class AuthLoginBody {\n");
|
StringBuilder unused3 = sb.Append("class AuthLoginBody {\n");
|
||||||
sb.Append(" Email: ").Append(Email).Append('\n');
|
StringBuilder unused2 = sb.Append(" Email: ").Append(Email).Append('\n');
|
||||||
sb.Append(" Password: ").Append(Password).Append('\n');
|
StringBuilder unused1 = sb.Append(" Password: ").Append(Password).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +64,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is null) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((AuthLoginBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((AuthLoginBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -76,20 +74,18 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(AuthLoginBody other)
|
public bool Equals(AuthLoginBody other)
|
||||||
{
|
{
|
||||||
if (other is null) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
Email == other.Email ||
|
Email == other.Email ||
|
||||||
Email != null &&
|
(Email != null &&
|
||||||
Email.Equals(other.Email)
|
Email.Equals(other.Email))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Password == other.Password ||
|
Password == other.Password ||
|
||||||
Password != null &&
|
(Password != null &&
|
||||||
Password.Equals(other.Password)
|
Password.Equals(other.Password))
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,12 +96,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (Email != null)
|
if (Email != null)
|
||||||
hashCode = hashCode * 59 + Email.GetHashCode();
|
hashCode = (hashCode * 59) + Email.GetHashCode();
|
||||||
if (Password != null)
|
if (Password != null)
|
||||||
hashCode = hashCode * 59 + Password.GetHashCode();
|
hashCode = (hashCode * 59) + Password.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,15 +109,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(AuthLoginBody left, AuthLoginBody right)
|
public static bool operator ==(AuthLoginBody left, AuthLoginBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(AuthLoginBody left, AuthLoginBody right)
|
public static bool operator !=(AuthLoginBody left, AuthLoginBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -63,13 +63,13 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class AuthRegisterBody {\n");
|
StringBuilder unused5 = sb.Append("class AuthRegisterBody {\n");
|
||||||
sb.Append(" FirstName: ").Append(FirstName).Append("\n");
|
StringBuilder unused4 = sb.Append(" FirstName: ").Append(FirstName).Append('\n');
|
||||||
sb.Append(" LastName: ").Append(LastName).Append("\n");
|
StringBuilder unused3 = sb.Append(" LastName: ").Append(LastName).Append('\n');
|
||||||
sb.Append(" Email: ").Append(Email).Append("\n");
|
StringBuilder unused2 = sb.Append(" Email: ").Append(Email).Append('\n');
|
||||||
sb.Append(" Password: ").Append(Password).Append("\n");
|
StringBuilder unused1 = sb.Append(" Password: ").Append(Password).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,9 +89,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((AuthRegisterBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((AuthRegisterBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -101,30 +99,27 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(AuthRegisterBody other)
|
public bool Equals(AuthRegisterBody other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((FirstName == other.FirstName ||
|
||||||
return
|
(FirstName != null &&
|
||||||
(
|
FirstName.Equals(other.FirstName))
|
||||||
FirstName == other.FirstName ||
|
|
||||||
FirstName != null &&
|
|
||||||
FirstName.Equals(other.FirstName)
|
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
LastName == other.LastName ||
|
LastName == other.LastName ||
|
||||||
LastName != null &&
|
(LastName != null &&
|
||||||
LastName.Equals(other.LastName)
|
LastName.Equals(other.LastName))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Email == other.Email ||
|
Email == other.Email ||
|
||||||
Email != null &&
|
(Email != null &&
|
||||||
Email.Equals(other.Email)
|
Email.Equals(other.Email))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Password == other.Password ||
|
Password == other.Password ||
|
||||||
Password != null &&
|
(Password != null &&
|
||||||
Password.Equals(other.Password)
|
Password.Equals(other.Password))
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -135,16 +130,16 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (FirstName != null)
|
if (FirstName != null)
|
||||||
hashCode = hashCode * 59 + FirstName.GetHashCode();
|
hashCode = (hashCode * 59) + FirstName.GetHashCode();
|
||||||
if (LastName != null)
|
if (LastName != null)
|
||||||
hashCode = hashCode * 59 + LastName.GetHashCode();
|
hashCode = (hashCode * 59) + LastName.GetHashCode();
|
||||||
if (Email != null)
|
if (Email != null)
|
||||||
hashCode = hashCode * 59 + Email.GetHashCode();
|
hashCode = (hashCode * 59) + Email.GetHashCode();
|
||||||
if (Password != null)
|
if (Password != null)
|
||||||
hashCode = hashCode * 59 + Password.GetHashCode();
|
hashCode = (hashCode * 59) + Password.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,15 +147,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(AuthRegisterBody left, AuthRegisterBody right)
|
public static bool operator ==(AuthRegisterBody left, AuthRegisterBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(AuthRegisterBody left, AuthRegisterBody right)
|
public static bool operator !=(AuthRegisterBody left, AuthRegisterBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -49,12 +49,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class CurrencyAddAssetBody {\n");
|
StringBuilder unused4 = sb.Append("class CurrencyAddAssetBody {\n");
|
||||||
sb.Append(" CollectionId: ").Append(CollectionId).Append("\n");
|
StringBuilder unused3 = sb.Append(" CollectionId: ").Append(CollectionId).Append('\n');
|
||||||
sb.Append(" AssetName: ").Append(AssetName).Append("\n");
|
StringBuilder unused2 = sb.Append(" AssetName: ").Append(AssetName).Append('\n');
|
||||||
sb.Append(" AssetLink: ").Append(AssetLink).Append("\n");
|
StringBuilder unused1 = sb.Append(" AssetLink: ").Append(AssetLink).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,9 +74,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((CurrencyAddAssetBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((CurrencyAddAssetBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -86,25 +84,23 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(CurrencyAddAssetBody other)
|
public bool Equals(CurrencyAddAssetBody other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
CollectionId == other.CollectionId ||
|
CollectionId == other.CollectionId ||
|
||||||
CollectionId != null &&
|
(CollectionId != null &&
|
||||||
CollectionId.Equals(other.CollectionId)
|
CollectionId.Equals(other.CollectionId))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
AssetName == other.AssetName ||
|
AssetName == other.AssetName ||
|
||||||
AssetName != null &&
|
(AssetName != null &&
|
||||||
AssetName.Equals(other.AssetName)
|
AssetName.Equals(other.AssetName))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
AssetLink == other.AssetLink ||
|
AssetLink == other.AssetLink ||
|
||||||
AssetLink != null &&
|
(AssetLink != null &&
|
||||||
AssetLink.Equals(other.AssetLink)
|
AssetLink.Equals(other.AssetLink))
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -115,14 +111,14 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (CollectionId != null)
|
if (CollectionId != null)
|
||||||
hashCode = hashCode * 59 + CollectionId.GetHashCode();
|
hashCode = (hashCode * 59) + CollectionId.GetHashCode();
|
||||||
if (AssetName != null)
|
if (AssetName != null)
|
||||||
hashCode = hashCode * 59 + AssetName.GetHashCode();
|
hashCode = (hashCode * 59) + AssetName.GetHashCode();
|
||||||
if (AssetLink != null)
|
if (AssetLink != null)
|
||||||
hashCode = hashCode * 59 + AssetLink.GetHashCode();
|
hashCode = (hashCode * 59) + AssetLink.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -130,15 +126,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(CurrencyAddAssetBody left, CurrencyAddAssetBody right)
|
public static bool operator ==(CurrencyAddAssetBody left, CurrencyAddAssetBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(CurrencyAddAssetBody left, CurrencyAddAssetBody right)
|
public static bool operator !=(CurrencyAddAssetBody left, CurrencyAddAssetBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -43,11 +43,11 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class CurrencyCreateBody {\n");
|
StringBuilder unused3 = sb.Append("class CurrencyCreateBody {\n");
|
||||||
sb.Append(" Name: ").Append(Name).Append('\n');
|
StringBuilder unused2 = sb.Append(" Name: ").Append(Name).Append('\n');
|
||||||
sb.Append(" Symbol: ").Append(Symbol).Append('\n');
|
StringBuilder unused1 = sb.Append(" Symbol: ").Append(Symbol).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,9 +67,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is null) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((CurrencyCreateBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((CurrencyCreateBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -79,20 +77,18 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(CurrencyCreateBody other)
|
public bool Equals(CurrencyCreateBody other)
|
||||||
{
|
{
|
||||||
if (other is null) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
Name == other.Name ||
|
Name == other.Name ||
|
||||||
Name != null &&
|
(Name != null &&
|
||||||
Name.Equals(other.Name)
|
Name.Equals(other.Name))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Symbol == other.Symbol ||
|
Symbol == other.Symbol ||
|
||||||
Symbol != null &&
|
(Symbol != null &&
|
||||||
Symbol.Equals(other.Symbol)
|
Symbol.Equals(other.Symbol))
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -103,12 +99,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (Name != null)
|
if (Name != null)
|
||||||
hashCode = hashCode * 59 + Name.GetHashCode();
|
hashCode = (hashCode * 59) + Name.GetHashCode();
|
||||||
if (Symbol != null)
|
if (Symbol != null)
|
||||||
hashCode = hashCode * 59 + Symbol.GetHashCode();
|
hashCode = (hashCode * 59) + Symbol.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,15 +112,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(CurrencyCreateBody left, CurrencyCreateBody right)
|
public static bool operator ==(CurrencyCreateBody left, CurrencyCreateBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(CurrencyCreateBody left, CurrencyCreateBody right)
|
public static bool operator !=(CurrencyCreateBody left, CurrencyCreateBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -33,10 +33,10 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class CurrencyCreateCollectionBody {\n");
|
StringBuilder unused2 = sb.Append("class CurrencyCreateCollectionBody {\n");
|
||||||
sb.Append(" CollectionName: ").Append(CollectionName).Append("\n");
|
StringBuilder unused1 = sb.Append(" CollectionName: ").Append(CollectionName).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,9 +56,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((CurrencyCreateCollectionBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((CurrencyCreateCollectionBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -68,15 +66,11 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(CurrencyCreateCollectionBody other)
|
public bool Equals(CurrencyCreateCollectionBody other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| CollectionName == other.CollectionName ||
|
||||||
return
|
(CollectionName != null &&
|
||||||
|
CollectionName.Equals(other.CollectionName)));
|
||||||
CollectionName == other.CollectionName ||
|
|
||||||
CollectionName != null &&
|
|
||||||
CollectionName.Equals(other.CollectionName)
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -87,10 +81,10 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (CollectionName != null)
|
if (CollectionName != null)
|
||||||
hashCode = hashCode * 59 + CollectionName.GetHashCode();
|
hashCode = (hashCode * 59) + CollectionName.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -98,15 +92,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right)
|
public static bool operator ==(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right)
|
public static bool operator !=(CurrencyCreateCollectionBody left, CurrencyCreateCollectionBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -43,11 +43,11 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class CurrencyMintBody {\n");
|
StringBuilder unused3 = sb.Append("class CurrencyMintBody {\n");
|
||||||
sb.Append(" CurrencyId: ").Append(CurrencyId).Append('\n');
|
StringBuilder unused2 = sb.Append(" CurrencyId: ").Append(CurrencyId).Append('\n');
|
||||||
sb.Append(" Amount: ").Append(Amount).Append('\n');
|
StringBuilder unused1 = sb.Append(" Amount: ").Append(Amount).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,9 +67,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is null) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((CurrencyMintBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((CurrencyMintBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -79,18 +77,16 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(CurrencyMintBody other)
|
public bool Equals(CurrencyMintBody other)
|
||||||
{
|
{
|
||||||
if (other is null) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
CurrencyId == other.CurrencyId ||
|
CurrencyId == other.CurrencyId ||
|
||||||
CurrencyId.Equals(other.CurrencyId)
|
CurrencyId.Equals(other.CurrencyId)
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Amount == other.Amount ||
|
Amount == other.Amount ||
|
||||||
Amount.Equals(other.Amount)
|
Amount.Equals(other.Amount)
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -105,15 +101,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(CurrencyMintBody left, CurrencyMintBody right)
|
public static bool operator ==(CurrencyMintBody left, CurrencyMintBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(CurrencyMintBody left, CurrencyMintBody right)
|
public static bool operator !=(CurrencyMintBody left, CurrencyMintBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -40,11 +40,11 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class WalletTransferDigitalBody {\n");
|
StringBuilder unused3 = sb.Append("class WalletTransferDigitalBody {\n");
|
||||||
sb.Append(" Email: ").Append(Email).Append("\n");
|
StringBuilder unused2 = sb.Append(" Email: ").Append(Email).Append('\n');
|
||||||
sb.Append(" AssetId: ").Append(AssetId).Append("\n");
|
StringBuilder unused1 = sb.Append(" AssetId: ").Append(AssetId).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +64,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, obj)) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((WalletTransferDigitalBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((WalletTransferDigitalBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -76,20 +74,18 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(WalletTransferDigitalBody other)
|
public bool Equals(WalletTransferDigitalBody other)
|
||||||
{
|
{
|
||||||
if (ReferenceEquals(null, other)) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
Email == other.Email ||
|
Email == other.Email ||
|
||||||
Email != null &&
|
(Email != null &&
|
||||||
Email.Equals(other.Email)
|
Email.Equals(other.Email))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
AssetId == other.AssetId ||
|
AssetId == other.AssetId ||
|
||||||
AssetId != null &&
|
(AssetId != null &&
|
||||||
AssetId.Equals(other.AssetId)
|
AssetId.Equals(other.AssetId))
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -100,12 +96,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (Email != null)
|
if (Email != null)
|
||||||
hashCode = hashCode * 59 + Email.GetHashCode();
|
hashCode = (hashCode * 59) + Email.GetHashCode();
|
||||||
if (AssetId != null)
|
if (AssetId != null)
|
||||||
hashCode = hashCode * 59 + AssetId.GetHashCode();
|
hashCode = (hashCode * 59) + AssetId.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,15 +109,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(WalletTransferDigitalBody left, WalletTransferDigitalBody right)
|
public static bool operator ==(WalletTransferDigitalBody left, WalletTransferDigitalBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(WalletTransferDigitalBody left, WalletTransferDigitalBody right)
|
public static bool operator !=(WalletTransferDigitalBody left, WalletTransferDigitalBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -59,12 +59,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>String presentation of the object</returns>
|
/// <returns>String presentation of the object</returns>
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
{
|
{
|
||||||
var sb = new StringBuilder();
|
StringBuilder sb = new();
|
||||||
sb.Append("class WalletTransferPhysicalBody {\n");
|
StringBuilder unused4 = sb.Append("class WalletTransferPhysicalBody {\n");
|
||||||
sb.Append(" DestUserEmail: ").Append(DestUserEmail).Append('\n');
|
StringBuilder unused3 = sb.Append(" DestUserEmail: ").Append(DestUserEmail).Append('\n');
|
||||||
sb.Append(" Amount: ").Append(Amount).Append('\n');
|
StringBuilder unused2 = sb.Append(" Amount: ").Append(Amount).Append('\n');
|
||||||
sb.Append(" CurrencyId: ").Append(CurrencyId).Append('\n');
|
StringBuilder unused1 = sb.Append(" CurrencyId: ").Append(CurrencyId).Append('\n');
|
||||||
sb.Append("}\n");
|
StringBuilder unused = sb.Append("}\n");
|
||||||
return sb.ToString();
|
return sb.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,9 +84,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public override bool Equals(object obj)
|
public override bool Equals(object obj)
|
||||||
{
|
{
|
||||||
if (obj is null) return false;
|
return obj is not null && (ReferenceEquals(this, obj) || (obj.GetType() == GetType() && Equals((WalletTransferPhysicalBody) obj)));
|
||||||
if (ReferenceEquals(this, obj)) return true;
|
|
||||||
return obj.GetType() == GetType() && Equals((WalletTransferPhysicalBody)obj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -96,14 +94,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
/// <returns>Boolean</returns>
|
/// <returns>Boolean</returns>
|
||||||
public bool Equals(WalletTransferPhysicalBody other)
|
public bool Equals(WalletTransferPhysicalBody other)
|
||||||
{
|
{
|
||||||
if (other is null) return false;
|
return other is not null
|
||||||
if (ReferenceEquals(this, other)) return true;
|
&& (ReferenceEquals(this, other)
|
||||||
|
|| ((
|
||||||
return
|
|
||||||
(
|
|
||||||
DestUserEmail == other.DestUserEmail ||
|
DestUserEmail == other.DestUserEmail ||
|
||||||
DestUserEmail != null &&
|
(DestUserEmail != null &&
|
||||||
DestUserEmail.Equals(other.DestUserEmail)
|
DestUserEmail.Equals(other.DestUserEmail))
|
||||||
) &&
|
) &&
|
||||||
(
|
(
|
||||||
Amount == other.Amount ||
|
Amount == other.Amount ||
|
||||||
@ -112,7 +108,7 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
(
|
(
|
||||||
CurrencyId == other.CurrencyId ||
|
CurrencyId == other.CurrencyId ||
|
||||||
CurrencyId.Equals(other.CurrencyId)
|
CurrencyId.Equals(other.CurrencyId)
|
||||||
);
|
)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -123,12 +119,12 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
{
|
{
|
||||||
unchecked // Overflow is fine, just wrap
|
unchecked // Overflow is fine, just wrap
|
||||||
{
|
{
|
||||||
var hashCode = 41;
|
int hashCode = 41;
|
||||||
// Suitable nullity checks etc, of course :)
|
// Suitable nullity checks etc, of course :)
|
||||||
if (DestUserEmail != null)
|
if (DestUserEmail != null)
|
||||||
hashCode = hashCode * 59 + DestUserEmail.GetHashCode();
|
hashCode = (hashCode * 59) + DestUserEmail.GetHashCode();
|
||||||
hashCode = hashCode * 59 + Amount.GetHashCode();
|
hashCode = (hashCode * 59) + Amount.GetHashCode();
|
||||||
hashCode = hashCode * 59 + CurrencyId.GetHashCode();
|
hashCode = (hashCode * 59) + CurrencyId.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -136,15 +132,9 @@ namespace IO.Swagger.Models.RequestDto
|
|||||||
#region Operators
|
#region Operators
|
||||||
#pragma warning disable 1591
|
#pragma warning disable 1591
|
||||||
|
|
||||||
public static bool operator ==(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right)
|
public static bool operator ==(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right) => Equals(left, right);
|
||||||
{
|
|
||||||
return Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool operator !=(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right)
|
public static bool operator !=(WalletTransferPhysicalBody left, WalletTransferPhysicalBody right) => !Equals(left, right);
|
||||||
{
|
|
||||||
return !Equals(left, right);
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma warning restore 1591
|
#pragma warning restore 1591
|
||||||
#endregion Operators
|
#endregion Operators
|
||||||
|
|||||||
@ -74,5 +74,4 @@ namespace IO.Swagger.Models.db
|
|||||||
/// </value>
|
/// </value>
|
||||||
public ICollection<Transaction> TransactionsTo { get; set; }
|
public ICollection<Transaction> TransactionsTo { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,10 @@ namespace IO.Swagger
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="args"></param>
|
/// <param name="args"></param>
|
||||||
/// <returns>IWebHostBuilder</returns>
|
/// <returns>IWebHostBuilder</returns>
|
||||||
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
|
public static IWebHostBuilder CreateWebHostBuilder(string[] args)
|
||||||
WebHost.CreateDefaultBuilder(args)
|
{
|
||||||
|
return WebHost.CreateDefaultBuilder(args)
|
||||||
.UseStartup<Startup>();
|
.UseStartup<Startup>();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -40,7 +40,7 @@ namespace IO.Swagger.Repositories
|
|||||||
if (await context.Currencies.AnyAsync(c => c.Symbol == request.Symbol || c.Name.ToLower() == request.Name.ToLower()))
|
if (await context.Currencies.AnyAsync(c => c.Symbol == request.Symbol || c.Name.ToLower() == request.Name.ToLower()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
await context.Currencies.AddAsync(new Currency
|
Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<Currency> unused = await context.Currencies.AddAsync(new Currency
|
||||||
{
|
{
|
||||||
Name = request.Name,
|
Name = request.Name,
|
||||||
Symbol = request.Symbol,
|
Symbol = request.Symbol,
|
||||||
@ -53,11 +53,11 @@ namespace IO.Swagger.Repositories
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<bool> MintCurrency(CurrencyMintBody request, int userId)
|
public async Task<bool> MintCurrency(CurrencyMintBody request, int userId)
|
||||||
{
|
{
|
||||||
var existsAndIsOwner = await context.Currencies.AnyAsync(c => c.CurrencyId == request.CurrencyId && c.UserId == userId);
|
bool existsAndIsOwner = await context.Currencies.AnyAsync(c => c.CurrencyId == request.CurrencyId && c.UserId == userId);
|
||||||
if (!existsAndIsOwner)
|
if (!existsAndIsOwner)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
await context.Transactions.AddAsync(new Transaction
|
Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<Transaction> unused = await context.Transactions.AddAsync(new Transaction
|
||||||
{
|
{
|
||||||
Amount = request.Amount,
|
Amount = request.Amount,
|
||||||
CurrencyId = request.CurrencyId,
|
CurrencyId = request.CurrencyId,
|
||||||
|
|||||||
@ -26,28 +26,29 @@ namespace IO.Swagger.Repositories
|
|||||||
this.context = context ?? throw new ArgumentNullException(nameof(context));
|
this.context = context ?? throw new ArgumentNullException(nameof(context));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<List<Transaction>> GetTransactionsForUser(int userId)
|
public async Task<List<Transaction>> GetTransactionsForUser(int userId)
|
||||||
{
|
{
|
||||||
var transactions = await context.Transactions.Where(t => t.ToUserId == userId || t.FromUserId == userId)
|
List<Transaction> transactions = await context.Transactions.Where(t => t.ToUserId == userId || t.FromUserId == userId)
|
||||||
.Include(t => t.Currency)
|
.Include(t => t.Currency)
|
||||||
.Include(t => t.FromUser)
|
.Include(t => t.FromUser)
|
||||||
.Include(t => t.ToUser)
|
.Include(t => t.ToUser)
|
||||||
.OrderByDescending(t => t.TransactionTime)
|
.OrderByDescending(t => t.TransactionTime)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
foreach (var t in transactions)
|
foreach (Transaction t in transactions)
|
||||||
|
{
|
||||||
if (t.ToUserId != t.FromUserId && t.FromUserId == userId)
|
if (t.ToUserId != t.FromUserId && t.FromUserId == userId)
|
||||||
t.Amount *= -1;
|
t.Amount *= -1;
|
||||||
|
}
|
||||||
|
|
||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<List<Tuple<Currency, float>>> GetBalancesForUser(int userId)
|
public async Task<List<Tuple<Currency, float>>> GetBalancesForUser(int userId)
|
||||||
{
|
{
|
||||||
var transactions = await context.Transactions.Where(t => t.ToUserId == userId || t.FromUserId == userId)
|
List<Tuple<Currency, float>> transactions = await context.Transactions.Where(t => t.ToUserId == userId || t.FromUserId == userId)
|
||||||
.Include(t => t.Currency)
|
.Include(t => t.Currency)
|
||||||
.GroupBy(t => t.Currency)
|
.GroupBy(t => t.Currency)
|
||||||
.Select(g => Tuple.Create(
|
.Select(g => Tuple.Create(
|
||||||
@ -63,22 +64,20 @@ namespace IO.Swagger.Repositories
|
|||||||
return transactions;
|
return transactions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public async Task<TransactionReturnCode> TransferPhysical(WalletTransferPhysicalBody request, int fromUserId)
|
public async Task<TransactionReturnCode> TransferPhysical(WalletTransferPhysicalBody request, int fromUserId)
|
||||||
{
|
{
|
||||||
var trimmedDest = request.DestUserEmail.Trim().ToLower();
|
string trimmedDest = request.DestUserEmail.Trim().ToLower();
|
||||||
var destUser = await context.Users.FirstOrDefaultAsync(u => u.Email == trimmedDest);
|
User destUser = await context.Users.FirstOrDefaultAsync(u => u.Email == trimmedDest);
|
||||||
if (destUser == null)
|
if (destUser == null)
|
||||||
return TransactionReturnCode.UnknownDestinationUser;
|
return TransactionReturnCode.UnknownDestinationUser;
|
||||||
|
|
||||||
var balances = await GetBalancesForUser(fromUserId);
|
List<Tuple<Currency, float>> balances = await GetBalancesForUser(fromUserId);
|
||||||
var balance = balances.FirstOrDefault(b => b.Item1.CurrencyId == request.CurrencyId);
|
Tuple<Currency, float> balance = balances.FirstOrDefault(b => b.Item1.CurrencyId == request.CurrencyId);
|
||||||
if (balance == null || balance.Item2 < request.Amount)
|
if (balance == null || balance.Item2 < request.Amount)
|
||||||
return TransactionReturnCode.InsufficientFunds;
|
return TransactionReturnCode.InsufficientFunds;
|
||||||
|
|
||||||
|
Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<Transaction> unused = await context.Transactions.AddAsync(new Transaction
|
||||||
await context.Transactions.AddAsync(new Transaction
|
|
||||||
{
|
{
|
||||||
Amount = request.Amount,
|
Amount = request.Amount,
|
||||||
CurrencyId = request.CurrencyId,
|
CurrencyId = request.CurrencyId,
|
||||||
@ -88,6 +87,5 @@ namespace IO.Swagger.Repositories
|
|||||||
});
|
});
|
||||||
return await context.SaveChangesAsync() > 0 ? TransactionReturnCode.Success : TransactionReturnCode.DbError;
|
return await context.SaveChangesAsync() > 0 ? TransactionReturnCode.Success : TransactionReturnCode.DbError;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ namespace IO.Swagger.Repositories
|
|||||||
string hashedPassword = Convert.ToBase64String(hashedBytes);
|
string hashedPassword = Convert.ToBase64String(hashedBytes);
|
||||||
|
|
||||||
// Create and insert the user
|
// Create and insert the user
|
||||||
var newUser = new User
|
User newUser = new()
|
||||||
{
|
{
|
||||||
PasswordHash = hashedPassword,
|
PasswordHash = hashedPassword,
|
||||||
Salt = salt,
|
Salt = salt,
|
||||||
@ -53,8 +53,8 @@ namespace IO.Swagger.Repositories
|
|||||||
LastName = request.LastName
|
LastName = request.LastName
|
||||||
};
|
};
|
||||||
|
|
||||||
await bankDbContext.Users.AddAsync(newUser);
|
Microsoft.EntityFrameworkCore.ChangeTracking.EntityEntry<User> unused1 = await bankDbContext.Users.AddAsync(newUser);
|
||||||
await bankDbContext.SaveChangesAsync();
|
int unused = await bankDbContext.SaveChangesAsync();
|
||||||
return newUser;
|
return newUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ namespace IO.Swagger.Repositories
|
|||||||
public async Task<User> LoginUser(AuthLoginBody request)
|
public async Task<User> LoginUser(AuthLoginBody request)
|
||||||
{
|
{
|
||||||
request.Email = request.Email.ToLower();
|
request.Email = request.Email.ToLower();
|
||||||
var user = await bankDbContext.Users.FirstOrDefaultAsync(u => u.Email.Equals(request.Email));
|
User user = await bankDbContext.Users.FirstOrDefaultAsync(u => u.Email.Equals(request.Email));
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -72,9 +72,7 @@ namespace IO.Swagger.Repositories
|
|||||||
byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes(saltedPassword);
|
byte[] passwordBytes = System.Text.Encoding.UTF8.GetBytes(saltedPassword);
|
||||||
byte[] hashedBytes = SHA256.HashData(passwordBytes);
|
byte[] hashedBytes = SHA256.HashData(passwordBytes);
|
||||||
string hashedPassword = Convert.ToBase64String(hashedBytes);
|
string hashedPassword = Convert.ToBase64String(hashedBytes);
|
||||||
if (hashedPassword != user.PasswordHash)
|
return hashedPassword != user.PasswordHash ? null : user;
|
||||||
return null;
|
|
||||||
return user;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|||||||
@ -44,12 +44,13 @@ namespace IO.Swagger.Security
|
|||||||
{
|
{
|
||||||
return AuthenticateResult.Fail("Missing Authorization Header");
|
return AuthenticateResult.Fail("Missing Authorization Header");
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]);
|
AuthenticationHeaderValue authHeader = AuthenticationHeaderValue.Parse(Request.Headers["Authorization"]);
|
||||||
|
|
||||||
var tokenHandler = new JwtSecurityTokenHandler();
|
JwtSecurityTokenHandler tokenHandler = new();
|
||||||
var validationParameters = new TokenValidationParameters
|
TokenValidationParameters validationParameters = new()
|
||||||
{
|
{
|
||||||
ValidateIssuerSigningKey = true,
|
ValidateIssuerSigningKey = true,
|
||||||
IssuerSigningKey = new SymmetricSecurityKey(secretBytes),
|
IssuerSigningKey = new SymmetricSecurityKey(secretBytes),
|
||||||
@ -59,15 +60,15 @@ namespace IO.Swagger.Security
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var claimsPrincipal = tokenHandler.ValidateToken(authHeader.Parameter, validationParameters, out _);
|
ClaimsPrincipal claimsPrincipal = tokenHandler.ValidateToken(authHeader.Parameter, validationParameters, out _);
|
||||||
var userIdClaim = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier);
|
Claim userIdClaim = claimsPrincipal.FindFirst(ClaimTypes.NameIdentifier);
|
||||||
|
|
||||||
if (userIdClaim != null && int.TryParse(userIdClaim.Value, out int userId))
|
if (userIdClaim != null && int.TryParse(userIdClaim.Value, out int userId))
|
||||||
{
|
{
|
||||||
var claims = new[] { new Claim(ClaimTypes.NameIdentifier, userId.ToString()) };
|
Claim[] claims = new[] { new Claim(ClaimTypes.NameIdentifier, userId.ToString()) };
|
||||||
var identity = new ClaimsIdentity(claims, SchemeName);
|
ClaimsIdentity identity = new(claims, SchemeName);
|
||||||
var principal = new ClaimsPrincipal(identity);
|
ClaimsPrincipal principal = new(identity);
|
||||||
var ticket = new AuthenticationTicket(principal, Scheme.Name);
|
AuthenticationTicket ticket = new(principal, Scheme.Name);
|
||||||
|
|
||||||
return AuthenticateResult.Success(ticket);
|
return AuthenticateResult.Success(ticket);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,7 +42,7 @@ namespace IO.Swagger.Services
|
|||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
|
|
||||||
// currency -> user FK
|
// currency -> user FK
|
||||||
modelBuilder.Entity<User>()
|
Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<User, Currency> unused3 = modelBuilder.Entity<User>()
|
||||||
.HasMany(u => u.Currencies)
|
.HasMany(u => u.Currencies)
|
||||||
.WithOne(c => c.User)
|
.WithOne(c => c.User)
|
||||||
.HasForeignKey(c => c.UserId)
|
.HasForeignKey(c => c.UserId)
|
||||||
@ -50,21 +50,21 @@ namespace IO.Swagger.Services
|
|||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
|
|
||||||
// transaction -> from user
|
// transaction -> from user
|
||||||
modelBuilder.Entity<User>()
|
Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<User, Transaction> unused2 = modelBuilder.Entity<User>()
|
||||||
.HasMany(u => u.TransactionsFrom)
|
.HasMany(u => u.TransactionsFrom)
|
||||||
.WithOne(t => t.FromUser)
|
.WithOne(t => t.FromUser)
|
||||||
.HasForeignKey(t => t.FromUserId)
|
.HasForeignKey(t => t.FromUserId)
|
||||||
.HasPrincipalKey(u => u.Id)
|
.HasPrincipalKey(u => u.Id)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
// transaction -> to user
|
// transaction -> to user
|
||||||
modelBuilder.Entity<User>()
|
Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<User, Transaction> unused1 = modelBuilder.Entity<User>()
|
||||||
.HasMany(u => u.TransactionsTo)
|
.HasMany(u => u.TransactionsTo)
|
||||||
.WithOne(t => t.ToUser)
|
.WithOne(t => t.ToUser)
|
||||||
.HasForeignKey(t => t.ToUserId)
|
.HasForeignKey(t => t.ToUserId)
|
||||||
.HasPrincipalKey(u => u.Id)
|
.HasPrincipalKey(u => u.Id)
|
||||||
.OnDelete(DeleteBehavior.NoAction);
|
.OnDelete(DeleteBehavior.NoAction);
|
||||||
// transaction -> currency
|
// transaction -> currency
|
||||||
modelBuilder.Entity<Transaction>()
|
Microsoft.EntityFrameworkCore.Metadata.Builders.ReferenceCollectionBuilder<Currency, Transaction> unused = modelBuilder.Entity<Transaction>()
|
||||||
.HasOne(t => t.Currency)
|
.HasOne(t => t.Currency)
|
||||||
.WithMany(c => c.Transactions)
|
.WithMany(c => c.Transactions)
|
||||||
.HasForeignKey(t => t.CurrencyId)
|
.HasForeignKey(t => t.CurrencyId)
|
||||||
|
|||||||
@ -30,20 +30,20 @@ namespace IO.Swagger.Services
|
|||||||
/// <returns>A JWT that will expire in 1hr from time of issue enconding the user id supplied</returns>
|
/// <returns>A JWT that will expire in 1hr from time of issue enconding the user id supplied</returns>
|
||||||
public string GenerateJwt(int userId)
|
public string GenerateJwt(int userId)
|
||||||
{
|
{
|
||||||
var claims = new[]
|
Claim[] claims = new[]
|
||||||
{
|
{
|
||||||
new Claim(ClaimTypes.NameIdentifier, userId.ToString())
|
new Claim(ClaimTypes.NameIdentifier, userId.ToString())
|
||||||
};
|
};
|
||||||
|
|
||||||
var tokenHandler = new JwtSecurityTokenHandler();
|
JwtSecurityTokenHandler tokenHandler = new();
|
||||||
var tokenDescriptor = new SecurityTokenDescriptor
|
SecurityTokenDescriptor tokenDescriptor = new()
|
||||||
{
|
{
|
||||||
Subject = new ClaimsIdentity(claims),
|
Subject = new ClaimsIdentity(claims),
|
||||||
Expires = DateTime.UtcNow.AddHours(1), // Token expiration time
|
Expires = DateTime.UtcNow.AddHours(1), // Token expiration time
|
||||||
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(secretBytes), SecurityAlgorithms.HmacSha256Signature)
|
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(secretBytes), SecurityAlgorithms.HmacSha256Signature)
|
||||||
};
|
};
|
||||||
|
|
||||||
var token = tokenHandler.CreateToken(tokenDescriptor);
|
SecurityToken token = tokenHandler.CreateToken(tokenDescriptor);
|
||||||
return tokenHandler.WriteToken(token);
|
return tokenHandler.WriteToken(token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,11 +16,11 @@ namespace IO.Swagger.Services
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public MapperProfile()
|
public MapperProfile()
|
||||||
{
|
{
|
||||||
CreateMap<User, UserDto>();
|
IMappingExpression<User, UserDto> unused3 = CreateMap<User, UserDto>();
|
||||||
CreateMap<Currency, CurrencyDto>();
|
IMappingExpression<Currency, CurrencyDto> unused2 = CreateMap<Currency, CurrencyDto>();
|
||||||
CreateMap<Transaction, TransactionDto>();
|
IMappingExpression<Transaction, TransactionDto> unused1 = CreateMap<Transaction, TransactionDto>();
|
||||||
|
|
||||||
CreateMap<Currency, CurrencyInfoDto>().ForMember(ci => ci.AmountInCirculation,
|
IMappingExpression<Currency, CurrencyInfoDto> unused = CreateMap<Currency, CurrencyInfoDto>().ForMember(ci => ci.AmountInCirculation,
|
||||||
mapper => mapper.MapFrom(c => c.Transactions.Where(t => t.ToUserId == t.FromUserId).Sum(t => t.Amount)))
|
mapper => mapper.MapFrom(c => c.Transactions.Where(t => t.ToUserId == t.FromUserId).Sum(t => t.Amount)))
|
||||||
.ForMember(ci => ci.CurrencyOwner,
|
.ForMember(ci => ci.CurrencyOwner,
|
||||||
mapper => mapper.MapFrom(c => c.User));
|
mapper => mapper.MapFrom(c => c.User));
|
||||||
|
|||||||
@ -16,10 +16,8 @@ using Microsoft.AspNetCore.Authentication;
|
|||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Microsoft.OpenApi.Models;
|
using Microsoft.OpenApi.Models;
|
||||||
using Newtonsoft.Json.Converters;
|
using Newtonsoft.Json.Converters;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
@ -35,17 +33,13 @@ namespace IO.Swagger
|
|||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment _hostingEnv;
|
private readonly IWebHostEnvironment _hostingEnv;
|
||||||
|
|
||||||
private IConfiguration Configuration { get; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Constructor
|
/// Constructor
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="env"></param>
|
/// <param name="env"></param>
|
||||||
/// <param name="configuration"></param>
|
public Startup(IWebHostEnvironment env)
|
||||||
public Startup(IWebHostEnvironment env, IConfiguration configuration)
|
|
||||||
{
|
{
|
||||||
_hostingEnv = env;
|
_hostingEnv = env;
|
||||||
Configuration = configuration;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -55,7 +49,7 @@ namespace IO.Swagger
|
|||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
// Add framework services.
|
// Add framework services.
|
||||||
services
|
IMvcBuilder unused11 = services
|
||||||
.AddMvc(options =>
|
.AddMvc(options =>
|
||||||
{
|
{
|
||||||
options.InputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter>();
|
options.InputFormatters.RemoveType<Microsoft.AspNetCore.Mvc.Formatters.SystemTextJsonInputFormatter>();
|
||||||
@ -68,11 +62,10 @@ namespace IO.Swagger
|
|||||||
})
|
})
|
||||||
.AddXmlSerializerFormatters();
|
.AddXmlSerializerFormatters();
|
||||||
|
|
||||||
services.AddAuthentication(BearerAuthenticationHandler.SchemeName)
|
AuthenticationBuilder unused10 = services.AddAuthentication(BearerAuthenticationHandler.SchemeName)
|
||||||
.AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null);
|
.AddScheme<AuthenticationSchemeOptions, BearerAuthenticationHandler>(BearerAuthenticationHandler.SchemeName, null);
|
||||||
|
|
||||||
|
IServiceCollection unused9 = services
|
||||||
services
|
|
||||||
.AddSwaggerGen(c =>
|
.AddSwaggerGen(c =>
|
||||||
{
|
{
|
||||||
c.SwaggerDoc("1.0.0", new OpenApiInfo
|
c.SwaggerDoc("1.0.0", new OpenApiInfo
|
||||||
@ -122,23 +115,16 @@ namespace IO.Swagger
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Auto Mapper Configurations
|
// Auto Mapper Configurations
|
||||||
var mapperConfig = new MapperConfiguration(mc =>
|
MapperConfiguration mapperConfig = new(mc => mc.AddProfile(new MapperProfile()));
|
||||||
{
|
|
||||||
mc.AddProfile(new MapperProfile());
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
// CORS sucks
|
// CORS sucks
|
||||||
services.AddCors(opt =>
|
IServiceCollection unused8 = services.AddCors(opt => opt.AddDefaultPolicy(po =>
|
||||||
{
|
|
||||||
opt.AddDefaultPolicy(po =>
|
|
||||||
{
|
{
|
||||||
po.AllowAnyHeader()
|
Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder unused7 = po.AllowAnyHeader()
|
||||||
.WithMethods("GET", "POST")
|
.WithMethods("GET", "POST")
|
||||||
.SetIsOriginAllowedToAllowWildcardSubdomains();
|
.SetIsOriginAllowedToAllowWildcardSubdomains();
|
||||||
po.SetIsOriginAllowed((or) => or.Contains("localhost") || or.Contains("shrukanslab"));
|
Microsoft.AspNetCore.Cors.Infrastructure.CorsPolicyBuilder unused6 = po.SetIsOriginAllowed((or) => or.Contains("localhost") || or.Contains("shrukanslab"));
|
||||||
});
|
}));
|
||||||
});
|
|
||||||
|
|
||||||
//Datase connections
|
//Datase connections
|
||||||
string connectionString = Environment.GetEnvironmentVariable("DATABASE_CONNECTION_STRING");
|
string connectionString = Environment.GetEnvironmentVariable("DATABASE_CONNECTION_STRING");
|
||||||
@ -149,13 +135,13 @@ namespace IO.Swagger
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DI setup
|
// DI setup
|
||||||
services.AddScoped<IUserRepository, UserRepository>();
|
IServiceCollection unused5 = services.AddScoped<IUserRepository, UserRepository>();
|
||||||
services.AddScoped<ICurrencyRepository, CurrencyRepository>();
|
IServiceCollection unused4 = services.AddScoped<ICurrencyRepository, CurrencyRepository>();
|
||||||
services.AddScoped<ITransactionRepository, TransactionRepository>();
|
IServiceCollection unused3 = services.AddScoped<ITransactionRepository, TransactionRepository>();
|
||||||
services.AddDbContext<BankDbContext>(x => x.UseSqlServer(connectionString: connectionString));
|
IServiceCollection unused2 = services.AddDbContext<BankDbContext>(x => x.UseSqlServer(connectionString: connectionString));
|
||||||
services.AddSingleton<JwtService>();
|
IServiceCollection unused1 = services.AddSingleton<JwtService>();
|
||||||
IMapper mapper = mapperConfig.CreateMapper();
|
IMapper mapper = mapperConfig.CreateMapper();
|
||||||
services.AddSingleton(mapper);
|
IServiceCollection unused = services.AddSingleton(mapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -163,45 +149,36 @@ namespace IO.Swagger
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="app"></param>
|
/// <param name="app"></param>
|
||||||
/// <param name="env"></param>
|
/// <param name="env"></param>
|
||||||
/// <param name="loggerFactory"></param>
|
|
||||||
/// <param name="context"></param>
|
/// <param name="context"></param>
|
||||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, BankDbContext context)
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, BankDbContext context)
|
||||||
{
|
{
|
||||||
context.Database.Migrate();
|
context.Database.Migrate();
|
||||||
app.UseRouting();
|
IApplicationBuilder unused8 = app.UseRouting();
|
||||||
|
|
||||||
app.UseCors();
|
IApplicationBuilder unused7 = app.UseCors();
|
||||||
|
|
||||||
app.UseAuthorization();
|
IApplicationBuilder unused6 = app.UseAuthorization();
|
||||||
|
|
||||||
app.UseSwagger();
|
IApplicationBuilder unused5 = app.UseSwagger();
|
||||||
app.UseSwaggerUI(c =>
|
IApplicationBuilder unused4 = app.UseSwaggerUI(c =>
|
||||||
{
|
|
||||||
//TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes)
|
//TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes)
|
||||||
c.SwaggerEndpoint("/swagger/1.0.0/swagger.json", "T&J Central Bank API");
|
c.SwaggerEndpoint("/swagger/1.0.0/swagger.json", "T&J Central Bank API"));
|
||||||
|
|
||||||
//TODO: Or alternatively use the original Swagger contract that's included in the static files
|
|
||||||
// c.SwaggerEndpoint("/swagger-original.json", "T&J Central Bank API Original");
|
|
||||||
});
|
|
||||||
|
|
||||||
//TODO: Use Https Redirection
|
//TODO: Use Https Redirection
|
||||||
// app.UseHttpsRedirection();
|
// app.UseHttpsRedirection();
|
||||||
|
|
||||||
app.UseEndpoints(endpoints =>
|
IApplicationBuilder unused3 = app.UseEndpoints(endpoints => endpoints.MapControllers());
|
||||||
{
|
|
||||||
endpoints.MapControllers();
|
|
||||||
});
|
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (env.IsDevelopment())
|
||||||
{
|
{
|
||||||
app.UseDeveloperExceptionPage();
|
IApplicationBuilder unused2 = app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//TODO: Enable production exception handling (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling)
|
//TODO: Enable production exception handling (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling)
|
||||||
app.UseExceptionHandler("/Error");
|
IApplicationBuilder unused1 = app.UseExceptionHandler("/Error");
|
||||||
|
|
||||||
app.UseHsts();
|
IApplicationBuilder unused = app.UseHsts();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user