Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions Libraries/Hypance.Core/Domain/Wallet/Wallet.cs
Original file line number Diff line number Diff line change
@@ -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; }
}
}

64 changes: 64 additions & 0 deletions Presenentation/Hypance.WebApi/Controllers/WalletController.cs
Original file line number Diff line number Diff line change
@@ -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<Wallet> _walletRepository;

public WalletController(IRepository<Wallet> walletRepository)
{
_walletRepository = walletRepository;
}

[HttpGet]
public List<Wallet> 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();
}
}
}