update
This commit is contained in:
@@ -7,8 +7,6 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Models.Account;
|
||||
using Models.Motion;
|
||||
using MyOffice.Data.Models.Accounts;
|
||||
using MyOffice.Web.Models.AccountMotion;
|
||||
using Services.Account;
|
||||
using Services.Account.Domain;
|
||||
|
||||
@@ -59,7 +57,7 @@ public class AccountController : BaseApiController
|
||||
}
|
||||
|
||||
[HttpGet("~/api/accounts/{id}/motions")]
|
||||
public object AccountMotionsGet(string id, [FromQuery] AccountMotionsGetModel request)
|
||||
public object MotionsGet(string id, [FromQuery] MotionsGetModel request)
|
||||
{
|
||||
var exec = _accountService.GetMotions(UserId, id!.AsGuid(), request.From.StartOfDay(), request.To.EndOfDay());
|
||||
|
||||
@@ -78,7 +76,7 @@ public class AccountController : BaseApiController
|
||||
}
|
||||
|
||||
[HttpPost("~/api/accounts/{id}/motions")]
|
||||
public object AccountsMotionsPost(string id, MotionRequest motion)
|
||||
public object MotionsPost(string id, MotionRequest motion)
|
||||
{
|
||||
var exec = _accountService.MotionAdd(UserId, id.AsGuid(), motion.FromModel());
|
||||
|
||||
@@ -95,4 +93,42 @@ public class AccountController : BaseApiController
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("~/api/accounts/{id}/motions/{motionId}")]
|
||||
public object MotionsPut(string id, string motionId, MotionRequest motion)
|
||||
{
|
||||
var exec = _accountService.MotionUpdate(UserId, id.AsGuid(), motionId.AsGuid(), motion.FromModel());
|
||||
|
||||
switch (exec.Status)
|
||||
{
|
||||
case MotionUpdateResult.not_found:
|
||||
return ProblemBadRequest("Motion not found.");
|
||||
case MotionUpdateResult.failure:
|
||||
return ProblemBadRequest("Updating motion failed.");
|
||||
case MotionUpdateResult.success:
|
||||
return exec.Result!.ToModel();
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("~/api/accounts/{id}/motions/{motionId}")]
|
||||
public object MotionsDelete(string id, string motionId)
|
||||
{
|
||||
var exec = _accountService.MotionRemove(UserId, id.AsGuid(), motionId.AsGuid());
|
||||
|
||||
switch (exec.Status)
|
||||
{
|
||||
case MotionDeleteResult.not_found:
|
||||
return ProblemBadRequest("Motion not found.");
|
||||
case MotionDeleteResult.failure:
|
||||
return ProblemBadRequest("Deliting motion failed.");
|
||||
case MotionDeleteResult.success:
|
||||
return exec.Result!.ToModel();
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user