-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Manish Kumar
committed
Nov 5, 2024
1 parent
97bd31e
commit 5997869
Showing
5 changed files
with
174 additions
and
6 deletions.
There are no files selected for viewing
28 changes: 28 additions & 0 deletions
28
Duc.Splitt/Duc.Splitt.Common/Dtos/Requests/OrderRequestDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using Duc.Splitt.Common.Enums; | ||
|
||
namespace Duc.Splitt.Common.Dtos.Requests | ||
{ | ||
public class OrderRequestDto | ||
{ | ||
public class CreateOrderRequestDto | ||
{ | ||
public Guid CustomerId { get; set; } | ||
public Guid MerchantId { get; set; } | ||
|
||
|
||
|
||
public List<CreaterOrderItemDto>? OrderItems { get; set; } | ||
} | ||
public class CreaterOrderItemDto | ||
{ | ||
} | ||
|
||
|
||
|
||
public class GetOrderRequestDetailsDto | ||
{ | ||
public Guid? OrderId { get; set; } | ||
public Guid? CustomerId { get; set; } | ||
} | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
Duc.Splitt/Duc.Splitt.Common/Dtos/Responses/OrderResponseDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Duc.Splitt.Common.Dtos.Requests; | ||
|
||
namespace Duc.Splitt.Common.Dtos.Responses | ||
{ | ||
public class OrderResponseDto | ||
{ | ||
|
||
|
||
public class CreaterOrderResponseDto | ||
{ | ||
public bool? IsSucess { get; set; } | ||
public Guid? OrderId { get; set; } | ||
public Guid? CustomerId { get; set; } | ||
} | ||
|
||
public class GetOrderDetailstResponseDto | ||
{ | ||
public Guid CustomerId { get; set; } | ||
public Guid MerchantId { get; set; } | ||
|
||
|
||
|
||
public List<GetOrderItemDto>? OrderItems { get; set; } | ||
} | ||
public class GetOrderItemDto | ||
{ | ||
} | ||
|
||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
Duc.Splitt/Duc.Splitt.CustomerApi/Controllers/OrderController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using Duc.Splitt.CustomerApi.Helper; | ||
using Duc.Splitt.Common.Dtos.Responses; | ||
using Duc.Splitt.Common.Enums; | ||
using Duc.Splitt.Core.Contracts.Services; | ||
using Duc.Splitt.Logger; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Azure.Core; | ||
using static System.Runtime.InteropServices.JavaScript.JSType; | ||
using static Duc.Splitt.Common.Dtos.Requests.OrderRequestDto; | ||
using static Duc.Splitt.Common.Dtos.Responses.OrderResponseDto; | ||
|
||
namespace Duc.Splitt.CustomerApi.Controllers | ||
{ | ||
|
||
public class OrderController : BaseAnonymous | ||
{ | ||
private readonly IOrderService _orderService; | ||
private readonly ILoggerService _logger; | ||
private IUtilsService _utilsService; | ||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); | ||
public OrderController(IOrderService orderService, ILoggerService logger, IUtilsService utilsService) | ||
{ | ||
_orderService = orderService; | ||
_logger = logger; | ||
_utilsService = utilsService; | ||
} | ||
|
||
|
||
[HttpPost()] | ||
public async Task<ResponseDto<CreaterOrderResponseDto?>> PostOrder(CreateOrderRequestDto requestDto) | ||
{ | ||
ResponseDto<CreaterOrderResponseDto?> response = new ResponseDto<CreaterOrderResponseDto?> | ||
{ | ||
Code = ResponseStatusCode.NoDataFound | ||
}; | ||
|
||
try | ||
{ | ||
var validateRequest = await _utilsService.ValidateRequest(this.Request, null); | ||
if (validateRequest == null) | ||
{ | ||
response.Code = ResponseStatusCode.InvalidToken; | ||
return response; | ||
} | ||
var obj = await _orderService.PostOrder(validateRequest, requestDto); | ||
return obj; | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex); | ||
response.Code = ResponseStatusCode.ServerError; | ||
response.Errors = _logger.ConvertExceptionToStringList(ex); | ||
return response; | ||
} | ||
} | ||
|
||
[HttpPost()] | ||
public async Task<ResponseDto<GetOrderDetailstResponseDto?>> GetOrderById(GetOrderRequestDetailsDto requestDto) | ||
{ | ||
ResponseDto<GetOrderDetailstResponseDto?> response = new ResponseDto<GetOrderDetailstResponseDto?> | ||
{ | ||
Code = ResponseStatusCode.NoDataFound | ||
}; | ||
|
||
try | ||
{ | ||
var validateRequest = await _utilsService.ValidateRequest(this.Request, null); | ||
if (validateRequest == null) | ||
{ | ||
response.Code = ResponseStatusCode.InvalidToken; | ||
return response; | ||
} | ||
var obj = await _orderService.GetOrderById(validateRequest, requestDto); | ||
return obj; | ||
} | ||
catch (Exception ex) | ||
{ | ||
_logger.LogError(ex); | ||
response.Code = ResponseStatusCode.ServerError; | ||
response.Errors = _logger.ConvertExceptionToStringList(ex); | ||
return response; | ||
} | ||
} | ||
|
||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters