This commit is contained in:
2023-07-31 08:50:05 +03:00
parent cca943f37d
commit c5d9ae7b93
49 changed files with 546 additions and 398 deletions
@@ -1,15 +1,15 @@
namespace MyOffice.Web.Controllers;
using AutoMapper;
using Core;
using Core.Extensions;
using Data.Models.Accounts;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Authorization;
using Core;
using Core.Extensions;
using Models.Account;
using Services.Account;
using Services.Account.Domain;
using MyOffice.Web.Infrastructure.Attributes;
using Infrastructure.Attributes;
using Services.Identity;
[Authorize]
@@ -52,7 +52,7 @@ public class SettingsAccountController : BaseApiController
{
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadRequest("Account category not found.");
return ProblemBadResponse("Account category not found.");
case GeneralExecStatus.success:
return _mapper.Map<AccountCategoryViewModel>(exec.Result!);
@@ -65,7 +65,7 @@ public class SettingsAccountController : BaseApiController
[HttpPost("~/api/settings/account-categories")]
public object AccountCategoriesAdd(AccountCategoryViewModel request)
{
var exec = _accountService.CategoryAdd(UserId, new AccountCategory { Name = request.Name! });
var exec = _accountService.CategoryAdd(UserId, new AccountCategoryDto { Name = request.Name! });
switch (exec.Status)
{
case GeneralExecStatus.success:
@@ -73,7 +73,7 @@ public class SettingsAccountController : BaseApiController
case GeneralExecStatus.failure:
case GeneralExecStatus.not_found:
return ProblemBadRequest("Adding account category failed.");
return ProblemBadResponse("Adding account category failed.");
default:
throw new NotSupportedException(exec.Status.ToString());
@@ -83,7 +83,7 @@ public class SettingsAccountController : BaseApiController
[HttpPut("~/api/settings/account-categories/{id}")]
public object AccountCategoriesEdit([AsGuid] string id, AccountCategoryViewModel request)
{
var exec = _accountService.CategoryUpdate(UserId, id.AsGuid(), new AccountCategory { Name = request.Name! });
var exec = _accountService.CategoryUpdate(UserId, id.AsGuid(), new AccountCategoryDto { Name = request.Name! });
switch (exec.Status)
{
case GeneralExecStatus.success:
@@ -91,7 +91,7 @@ public class SettingsAccountController : BaseApiController
case GeneralExecStatus.failure:
case GeneralExecStatus.not_found:
return ProblemBadRequest("Update account category failed.");
return ProblemBadResponse("Update account category failed.");
default:
throw new NotSupportedException(exec.Status.ToString());
@@ -108,11 +108,11 @@ public class SettingsAccountController : BaseApiController
return exec.Result!;
case AccountCategoryRemoveResult.failure:
return ProblemBadRequest("Remove account category failed.");
return ProblemBadResponse("Remove account category failed.");
case AccountCategoryRemoveResult.not_found:
return ProblemBadRequest("Account category not found.");
return ProblemBadResponse("Account category not found.");
case AccountCategoryRemoveResult.accounts_exists:
return ProblemBadRequest("Account category have accounts.");
return ProblemBadResponse("Account category have accounts.");
default:
throw new NotSupportedException(exec.Status.ToString());
@@ -143,11 +143,11 @@ public class SettingsAccountController : BaseApiController
switch (exec.Status)
{
case AccountAddStatus.category_not_found:
return ProblemBadRequest("Category not found.");
return ProblemBadResponse("Category not found.");
case AccountAddStatus.currency_not_found:
return ProblemBadRequest("Currency not found.");
return ProblemBadResponse("Currency not found.");
case AccountAddStatus.failure:
return ProblemBadRequest("Adding account failed.");
return ProblemBadResponse("Adding account failed.");
case AccountAddStatus.success:
return exec.Result!;
@@ -172,13 +172,13 @@ public class SettingsAccountController : BaseApiController
switch (exec.Status)
{
case AccountEditStatus.not_found:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case AccountEditStatus.category_not_found:
return ProblemBadRequest("Category not found.");
return ProblemBadResponse("Category not found.");
case AccountEditStatus.currency_not_found:
return ProblemBadRequest("Currency not found.");
return ProblemBadResponse("Currency not found.");
case AccountEditStatus.failure:
return ProblemBadRequest("Adding account failed.");
return ProblemBadResponse("Adding account failed.");
case AccountEditStatus.success:
return exec.Result!;
@@ -194,7 +194,7 @@ public class SettingsAccountController : BaseApiController
switch (exec.Status)
{
case GeneralExecStatus.not_found:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case GeneralExecStatus.success:
return exec.Result!;
@@ -212,7 +212,7 @@ public class SettingsAccountController : BaseApiController
{
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadRequest("Category not found.");
return ProblemBadResponse("Category not found.");
case GeneralExecStatus.success:
return exec.Result!;
@@ -233,7 +233,7 @@ public class SettingsAccountController : BaseApiController
{
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case GeneralExecStatus.success:
break;
@@ -252,7 +252,7 @@ public class SettingsAccountController : BaseApiController
switch (inviteExec.Status)
{
case AccessInviteStatus.account_not_found:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case AccessInviteStatus.access_exists:
case AccessInviteStatus.invite_exists:
@@ -273,7 +273,7 @@ public class SettingsAccountController : BaseApiController
{
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case GeneralExecStatus.success:
return exec.Result!;
@@ -299,9 +299,9 @@ public class SettingsAccountController : BaseApiController
switch (exec.Status)
{
case InviteAcceptStatus.invite_not_found:
return ProblemBadRequest("Invite not found.");
return ProblemBadResponse("Invite not found.");
case InviteAcceptStatus.account_not_found:
return ProblemBadRequest("Account not found.");
return ProblemBadResponse("Account not found.");
case InviteAcceptStatus.already_accepted:
case InviteAcceptStatus.success:
@@ -321,7 +321,7 @@ public class SettingsAccountController : BaseApiController
{
case GeneralExecStatus.not_found:
case GeneralExecStatus.failure:
return ProblemBadRequest("Invite not found.");
return ProblemBadResponse("Invite not found.");
case GeneralExecStatus.success:
return _mapper.Map<AccountAccessInviteViewModel>(exec.Result!);