fix
This commit is contained in:
@@ -308,7 +308,7 @@
|
||||
|
||||
if (!_accountMotionRepository.Add(accountMotionDb))
|
||||
{
|
||||
return result.Set(GeneralExecStatus.failure);
|
||||
return result.Set(AccountMotionAddResult.failure);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
{
|
||||
public DateTime Date { get; set; }
|
||||
public string Motion { get; set; } = null!;
|
||||
public string Description { get; set; } = null!;
|
||||
public string? Description { get; set; };
|
||||
public decimal Plus { get; set; }
|
||||
public decimal Minus { get; set; }
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ using Core.Extensions;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Models.Account;
|
||||
using MyOffice.Data.Models.Accounts;
|
||||
using MyOffice.Web.Models.AccountMotion;
|
||||
using Services.Account;
|
||||
using Services.Account.Domain;
|
||||
|
||||
[Authorize]
|
||||
[ApiController]
|
||||
@@ -43,8 +45,18 @@ public class AccountController : BaseApiController
|
||||
[HttpPost("~/api/accounts/{id}/motions")]
|
||||
public object AccountsMotionsPost(string id, AccountMotionRequest accountMotion)
|
||||
{
|
||||
var list = _accountService.GetByCategoryDetailed(UserId, category!.AsGuid());
|
||||
var exec = _accountService.AccountMotionAdd(UserId, id.AsGuid(), accountMotion.FromModel());
|
||||
switch (exec.Status)
|
||||
{
|
||||
case AccountMotionAddResult.account_not_found:
|
||||
return ProblemBadRequest("Account failed.");
|
||||
case AccountMotionAddResult.failure:
|
||||
return ProblemBadRequest("Adding motion failed.");
|
||||
case AccountMotionAddResult.success:
|
||||
return exec.Result!;
|
||||
|
||||
return list.Select(x => x.ToModel());
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
namespace MyOffice.Web.Models.AccountMotion;
|
||||
|
||||
using Data.Models.Accounts;
|
||||
using Services.Account.Domain;
|
||||
|
||||
public class AccountMotionViewModel
|
||||
{
|
||||
@@ -27,13 +28,16 @@ public static class AccountMotionViewModelExtension
|
||||
|
||||
public static class AccountMotionRequestExtension
|
||||
{
|
||||
public static AccountMotion FromModel(this AccountMotionRequest input)
|
||||
public static AccountMotionAdd FromModel(this AccountMotionRequest input)
|
||||
{
|
||||
/*return new AccountMotion
|
||||
return new AccountMotionAdd
|
||||
{
|
||||
CreatedOn = input.Date,
|
||||
mo
|
||||
};*/
|
||||
Date = input.Date,
|
||||
Motion = input.Motion,
|
||||
Minus = input.Minus,
|
||||
Plus = input.Plus,
|
||||
Description = input.Description,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user