This commit is contained in:
2023-07-25 22:10:03 +03:00
parent ce2ae68c9f
commit 5ecefe5756
30 changed files with 2321 additions and 123 deletions
@@ -3,6 +3,7 @@ namespace MyOffice.Web.Controllers;
using AutoMapper;
using Core;
using Core.Extensions;
using Data.Models.Accounts;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
@@ -76,7 +77,8 @@ public class AccountController : BaseApiController
return ProblemBadRequest("Account not found.");
case GeneralExecStatus.success:
return exec.Result!.Select(x => x.ToModel());
//return exec.Result!.Select(x => x.ToModel());
return _mapper.Map<MotionViewModel[]>(exec.Result!);
default:
throw new NotSupportedException(exec.Status.ToString());
@@ -86,7 +88,7 @@ public class AccountController : BaseApiController
[HttpPost("~/api/accounts/{id}/motions")]
public object MotionsPost(string id, MotionRequest motion)
{
var exec = _accountService.MotionAdd(UserId, id.AsGuid(), motion.FromModel());
var exec = _accountService.MotionAdd(UserId, id.AsGuid(), _mapper.Map<MotionAddUpdate>(motion));
switch (exec.Status)
{
@@ -95,7 +97,7 @@ public class AccountController : BaseApiController
case MotionAddResult.failure:
return ProblemBadRequest("Adding motion failed.");
case MotionAddResult.success:
return exec.Result!.ToModel();
return _mapper.Map<MotionViewModel[]>(exec.Result!);
default:
throw new NotSupportedException(exec.Status.ToString());
@@ -105,7 +107,7 @@ public class AccountController : BaseApiController
[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());
var exec = _accountService.MotionUpdate(UserId, id.AsGuid(), motionId.AsGuid(), _mapper.Map<MotionAddUpdate>(motion));
switch (exec.Status)
{
@@ -154,7 +156,7 @@ public class AccountController : BaseApiController
foreach (var account in accounts)
{
var accountName = $"+{account.Name}";
var item = items.FirstOrDefault(x => x.Name == accountName);
var item = items.FirstOrDefault(x => x.Name.IsPresent() && x.Name!.Length > 1 && x.Name.Substring(1) == accountName);
if (item == null)
{