-
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.
Push Activity, Asset Attributes, Payments and Transactions (C,R,U,D) (#…
…12) * Update data type for value (Transaction) * Activity, Asset Attributes, Payments and Transactions C,R,U,D
- Loading branch information
1 parent
56471ef
commit 3bd852c
Showing
24 changed files
with
1,460 additions
and
49 deletions.
There are no files selected for viewing
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
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,58 @@ | ||
using DomainLayer.Constants; | ||
using DomainLayer.Entities; | ||
using Microsoft.AspNetCore.Mvc; | ||
using RepositoryLayer.Repositories; | ||
using ServiceLayer.Business; | ||
using WebApiLayer.UserFeatures.Requests; | ||
|
||
namespace WebApiLayer.Controllers; | ||
|
||
[Route(Constants.HTTP.API_VERSION + "/gms/asset-attributes")] | ||
public class AssetAttributesController : BaseController | ||
{ | ||
private readonly IAssetAttributeServices _assetAttServices; | ||
private readonly IGenericRepository<AssetAttributeEntity> _assetAttRepo; | ||
public AssetAttributesController(IAssetAttributeServices assetAttServices, IGenericRepository<AssetAttributeEntity> assetAttRepo) | ||
{ | ||
_assetAttServices = assetAttServices; | ||
_assetAttRepo = assetAttRepo; | ||
} | ||
|
||
[HttpGet] | ||
public async Task<IActionResult> GetAssetAttributes() | ||
{ | ||
return Ok(await _assetAttServices.List()); | ||
} | ||
|
||
[HttpGet("{id}")] | ||
public async Task<IActionResult> GetAssetAttribute(Guid id) | ||
{ | ||
return Ok(await _assetAttServices.GetById(id)); | ||
} | ||
|
||
[HttpPost] | ||
public async Task<IActionResult> CreateAssetAttribute([FromBody] CreateAssetAttributeRequest assetAtt) | ||
{ | ||
var newAssAtt = new AssetAttributeEntity(); | ||
Mapper.Map(assetAtt, newAssAtt); | ||
await _assetAttServices.Create(newAssAtt); | ||
return CreatedAtAction(nameof(GetAssetAttribute), new { id = newAssAtt.Id }, newAssAtt); | ||
} | ||
|
||
[HttpPut("{id}")] | ||
public async Task<IActionResult> UpdateAssetAttribute(Guid id, [FromBody] UpdateAssetAttributeRequest assetAtt) | ||
{ | ||
var updateAssAtt = await _assetAttRepo.FoundOrThrowAsync(id, "Asset attribute not exist."); | ||
Mapper.Map(assetAtt, updateAssAtt); | ||
await _assetAttServices.Update(updateAssAtt); | ||
return Ok(updateAssAtt); | ||
} | ||
|
||
[HttpDelete("{id}")] | ||
public async Task<IActionResult> DeleteAssetAttribute(Guid id) | ||
{ | ||
await _assetAttRepo.FoundOrThrowAsync(id, "Asset attribute not exist."); | ||
await _assetAttServices.Delete(id); | ||
return NoContent(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,35 +1,57 @@ | ||
using DomainLayer.Constants; | ||
using DomainLayer.Entities; | ||
using Microsoft.AspNetCore.Mvc; | ||
using RepositoryLayer.Repositories; | ||
using ServiceLayer.Business; | ||
using WebApiLayer.UserFeatures.Requests; | ||
|
||
namespace WebApiLayer.Controllers; | ||
|
||
[Route(Constants.HTTP.API_VERSION + "/gms/payments")] | ||
public class PaymentsController : BaseController | ||
{ | ||
private readonly IPaymentServices _paymentServices; | ||
private readonly IGenericRepository<PaymentEntity> _paymentRepo; | ||
public PaymentsController(IPaymentServices paymentServices, IGenericRepository<PaymentEntity> paymentRepo) | ||
{ | ||
_paymentServices = paymentServices; | ||
_paymentRepo = paymentRepo; | ||
} | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
public async Task<IActionResult> GetPayments() | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
return Ok(await _paymentServices.List()); | ||
} | ||
|
||
[HttpGet("{id}")] | ||
public string Get(int id) | ||
public async Task<IActionResult> GetPayment(Guid id) | ||
{ | ||
return "value"; | ||
return Ok(await _paymentServices.List()); | ||
} | ||
|
||
[HttpPost] | ||
public void Post([FromBody] string value) | ||
public async Task<IActionResult> CreatePayment([FromBody] CreatePaymentRequest payment) | ||
{ | ||
var newPayment = new PaymentEntity(); | ||
Mapper.Map(payment, newPayment); | ||
await _paymentServices.Create(newPayment); | ||
return CreatedAtAction(nameof(GetPayment),new {id = newPayment.Id}, newPayment); | ||
} | ||
|
||
[HttpPut("{id}")] | ||
public void Put(int id, [FromBody] string value) | ||
public async Task<IActionResult> UpdatePayment(Guid id, [FromBody] UpdatePaymentRequest payment) | ||
{ | ||
var updatePayment = await _paymentRepo.FoundOrThrowAsync(id,"Payment not exist"); | ||
Mapper.Map(payment, updatePayment); | ||
await _paymentServices.Update(updatePayment); | ||
return Ok(updatePayment); | ||
} | ||
|
||
[HttpDelete("{id}")] | ||
public void Delete(int id) | ||
public async Task<IActionResult> DeletePayment(Guid id) | ||
{ | ||
await _paymentRepo.FoundOrThrowAsync(id, "Payment not exist"); | ||
await _paymentServices.Delete(id); | ||
return NoContent(); | ||
} | ||
} |
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 |
---|---|---|
@@ -1,35 +1,58 @@ | ||
using DomainLayer.Constants; | ||
using DomainLayer.Entities; | ||
using Microsoft.AspNetCore.Mvc; | ||
using RepositoryLayer.Repositories; | ||
using ServiceLayer.Business; | ||
using System.Diagnostics; | ||
using WebApiLayer.UserFeatures.Requests; | ||
|
||
namespace WebApiLayer.Controllers; | ||
|
||
[Route(Constants.HTTP.API_VERSION + "/gms/transactions")] | ||
public class TransactionsController : BaseController | ||
{ | ||
private readonly ITransactionServices _transactionServices; | ||
private readonly IGenericRepository<TransactionEntity> _transactionRepo; | ||
public TransactionsController(ITransactionServices transactionServices, IGenericRepository<TransactionEntity> transactionRepo) | ||
{ | ||
_transactionServices = transactionServices; | ||
_transactionRepo = transactionRepo; | ||
} | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
public async Task<IActionResult> GetTransactions() | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
return Ok(await _transactionServices.List()); | ||
} | ||
|
||
[HttpGet("{id}")] | ||
public string Get(int id) | ||
public async Task<IActionResult> GetTransaction(Guid id) | ||
{ | ||
return "value"; | ||
return Ok(await _transactionServices.GetById(id)); | ||
} | ||
|
||
[HttpPost] | ||
public void Post([FromBody] string value) | ||
public async Task<IActionResult> CreateTransaction([FromBody] CreateTransactionRequest trans) | ||
{ | ||
var newTrans = new TransactionEntity(); | ||
Mapper.Map(trans, newTrans); | ||
await _transactionServices.Create(newTrans); | ||
return CreatedAtAction(nameof(GetTransaction),new { id = newTrans.Id }, newTrans ); | ||
} | ||
|
||
[HttpPut("{id}")] | ||
public void Put(int id, [FromBody] string value) | ||
public async Task<IActionResult> UpdateTransaction(Guid id, [FromBody] UpdateTransactionRequest trans) | ||
{ | ||
var updateTrans = await _transactionRepo.FoundOrThrowAsync(id, "Transaction not exist."); | ||
Mapper.Map(trans, updateTrans); | ||
await _transactionServices.Update(updateTrans); | ||
return Ok(updateTrans); | ||
} | ||
|
||
[HttpDelete("{id}")] | ||
public void Delete(int id) | ||
public async Task<IActionResult> DeleteTransaction(Guid id) | ||
{ | ||
await _transactionRepo.FoundOrThrowAsync(id, "Transaction not exist."); | ||
await _transactionServices.Delete(id); | ||
return NoContent(); | ||
} | ||
} |
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,18 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class CreateActivityRequest : IMapTo<ActivityEntity>, IMapFrom<ActivityEntity> | ||
{ | ||
[Required] | ||
public string Name { get; set; } | ||
[Required] | ||
public int Status { get; set; } | ||
[Required] | ||
public Guid ActivityTypeId { get; set; } | ||
[Required] | ||
public Guid TransactionId { get; set; } | ||
} | ||
} |
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,16 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class CreateAssetAttributeRequest : IMapFrom<AssetAttributeEntity>, IMapTo<AssetAttributeEntity> | ||
{ | ||
[Required] | ||
public int Value { get; set; } | ||
[Required] | ||
public Guid AssetId { get; set; } | ||
[Required] | ||
public Guid AttributeGroupId { get; set; } | ||
} | ||
} |
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 DomainLayer.Entities; | ||
using System.ComponentModel; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class CreatePaymentRequest : IMapTo<PaymentEntity>, IMapFrom<PaymentEntity> | ||
{ | ||
[Required] | ||
public int Amount { get; set; } | ||
[Required] | ||
public DateTime Date { get; set; } = DateTime.UtcNow; | ||
[Required] | ||
public string Content { get; set; } | ||
[Required] | ||
public string BankCode { get; set; } | ||
[Required] | ||
public string Status { get; set; } | ||
[Required] | ||
public Guid CharacterId { get; set; } | ||
[Required] | ||
public Guid UserId { get; set; } | ||
[Required] | ||
public Guid WalletId { get; set; } | ||
|
||
} | ||
} |
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,16 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class CreateTransactionRequest : IMapTo<TransactionEntity>, IMapFrom<TransactionEntity> | ||
{ | ||
[Required] | ||
public string Name { get; set; } | ||
[Required] | ||
public float Value { get; set; } | ||
[Required] | ||
public Guid WalletId { get; set; } | ||
} | ||
} |
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,12 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class UpdateActivityRequest : IMapTo<ActivityEntity>, IMapFrom<ActivityEntity> | ||
{ | ||
public string? Name { get; set; } | ||
public int? Status { get; set; } | ||
} | ||
} |
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,11 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class UpdateAssetAttributeRequest : IMapFrom<AssetAttributeEntity>, IMapTo<AssetAttributeEntity> | ||
{ | ||
public int? Value { get; set; } | ||
} | ||
} |
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,14 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class UpdatePaymentRequest : IMapTo<PaymentEntity>, IMapFrom<PaymentEntity> | ||
{ | ||
public int? Amount { get; set; } | ||
public string? Content { get; set; } | ||
public string? BankCode { get; set; } | ||
public string? Status { get; set; } | ||
} | ||
} |
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,12 @@ | ||
using DomainLayer.Entities; | ||
using System.ComponentModel.DataAnnotations; | ||
using WebApiLayer.Mappings; | ||
|
||
namespace WebApiLayer.UserFeatures.Requests | ||
{ | ||
public class UpdateTransactionRequest : IMapTo<TransactionEntity>, IMapFrom<TransactionEntity> | ||
{ | ||
public string? Name { get; set; } | ||
public float? Value { get; set; } | ||
} | ||
} |
Oops, something went wrong.