From cdf00e8f5a04b7d66b804c83be568d61c89323e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eda=20=C5=9Eent=C3=BCrk?= Date: Mon, 5 Dec 2022 19:36:29 +0300 Subject: [PATCH 1/2] Added Wallet Class --- Libraries/Hypance.Core/Domain/Wallet/Wallet.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 Libraries/Hypance.Core/Domain/Wallet/Wallet.cs diff --git a/Libraries/Hypance.Core/Domain/Wallet/Wallet.cs b/Libraries/Hypance.Core/Domain/Wallet/Wallet.cs new file mode 100644 index 0000000..04b729c --- /dev/null +++ b/Libraries/Hypance.Core/Domain/Wallet/Wallet.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Hypance.Core.Domain.Wallet +{ + public class Wallet : BaseEntity + { + public decimal Balance { get; set; } + } +} + From f1a203b93da139a3f65caa818b437dea037c47d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eda=20=C5=9Eent=C3=BCrk?= Date: Mon, 5 Dec 2022 20:15:54 +0300 Subject: [PATCH 2/2] Added Wallet Controller --- .../Controllers/WalletController.cs | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 Presenentation/Hypance.WebApi/Controllers/WalletController.cs diff --git a/Presenentation/Hypance.WebApi/Controllers/WalletController.cs b/Presenentation/Hypance.WebApi/Controllers/WalletController.cs new file mode 100644 index 0000000..028b57a --- /dev/null +++ b/Presenentation/Hypance.WebApi/Controllers/WalletController.cs @@ -0,0 +1,64 @@ +using System; +using Hypance.Core.Domain.Wallet; +using Hypance.Data; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using System.Collections.Generic; + +namespace Hypance.WebApi.Controllers +{ + [ApiController] + [Route("[controller]/[action]")] + public class WalletController : Controller + { + private readonly IRepository _walletRepository; + + public WalletController(IRepository walletRepository) + { + _walletRepository = walletRepository; + } + + [HttpGet] + public List GetAll() + { + var model = _walletRepository.GetAll(); + return model.Data; + } + + [HttpGet("{id}")] + public Wallet Get(int id) + { + var model = _walletRepository.Get(x => x.Id == id); + if (model.Success) + return model.Data; + return new Wallet(); + } + + [HttpPost] + public IActionResult Post(Wallet wallet) + { + var result = _walletRepository.Add(wallet); + if (result.Success) + return Ok(); + return BadRequest(); + } + + [HttpPut] + public IActionResult Put(Wallet wallet) + { + var result = _walletRepository.Update(wallet); + if (result.Success) + return Ok(); + return BadRequest(); + } + + [HttpDelete] + public IActionResult Delete(Wallet wallet) + { + var result = _walletRepository.Delete(wallet); + if (result.Success) + return Ok(); + return BadRequest(); + } + } +} \ No newline at end of file