fix
This commit is contained in:
@@ -43,7 +43,7 @@ public class SettingsAccountController : BaseApiController
|
||||
return OkResponse(_mapper.Map<List<AccountViewModel>>(list.OrderBy(x => x.Name)));
|
||||
}
|
||||
|
||||
public object AccountsAdd(AccountViewModel request)
|
||||
public ObjectResult AccountsAdd(AccountViewModel request)
|
||||
{
|
||||
var exec = _accountService.AccountAdd(UserId, new AccountAdd
|
||||
{
|
||||
@@ -62,15 +62,14 @@ public class SettingsAccountController : BaseApiController
|
||||
case AccountAddStatus.failure:
|
||||
return ProblemBadResponse("Adding account failed.");
|
||||
case AccountAddStatus.success:
|
||||
return _mapper.Map<AccountViewModel>(exec.Result!);
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public object AccountsUpdate([AsGuid] string id, AccountEditRequestModel request)
|
||||
public ObjectResult AccountsUpdate([AsGuid] string id, AccountEditRequestModel request)
|
||||
{
|
||||
var exec = _accountService.AccountUpdate(UserId, id.AsGuid(), new AccountEdit
|
||||
{
|
||||
@@ -92,14 +91,14 @@ public class SettingsAccountController : BaseApiController
|
||||
case AccountEditStatus.failure:
|
||||
return ProblemBadResponse("Adding account failed.");
|
||||
case AccountEditStatus.success:
|
||||
return _mapper.Map<AccountViewModel>(exec.Result!);
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object AccountsDelete([AsGuid] string id)
|
||||
public ObjectResult AccountsDelete([AsGuid] string id)
|
||||
{
|
||||
var exec = _accountService.AccountDelete(UserId, id);
|
||||
switch (exec.Status)
|
||||
@@ -107,14 +106,14 @@ public class SettingsAccountController : BaseApiController
|
||||
case GeneralExecStatus.not_found:
|
||||
return ProblemBadResponse("Account not found.");
|
||||
case GeneralExecStatus.success:
|
||||
return _mapper.Map<AccountViewModel>(exec.Result!);
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object AccountsCategoryDelete([AsGuid] string id, [AsGuid] string categoryId)
|
||||
public ObjectResult AccountsCategoryDelete([AsGuid] string id, [AsGuid] string categoryId)
|
||||
{
|
||||
var exec = _accountService.AccountCategoryRemove(UserId, id.AsGuid(), categoryId.AsGuid());
|
||||
|
||||
@@ -125,14 +124,14 @@ public class SettingsAccountController : BaseApiController
|
||||
return ProblemBadResponse("Category not found.");
|
||||
|
||||
case GeneralExecStatus.success:
|
||||
return exec.Result!;
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object AccountsAccessAdd([AsGuid] string id, AccountAccessViewModel request)
|
||||
public ObjectResult AccountsAccessAdd([AsGuid] string id, AccountAccessViewModel request)
|
||||
{
|
||||
var model = _mapper.Map<List<AccountAccessDto>>(request.Accesses);
|
||||
|
||||
@@ -153,7 +152,7 @@ public class SettingsAccountController : BaseApiController
|
||||
|
||||
if (!request.Email.IsPresent())
|
||||
{
|
||||
return exec.Result!;
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
}
|
||||
|
||||
var inviteExec = _accountService.AccessInvite(UserId, id.AsGuid(), request.Email!, request.AllowWrite);
|
||||
@@ -166,14 +165,14 @@ public class SettingsAccountController : BaseApiController
|
||||
case AccessInviteStatus.access_exists:
|
||||
case AccessInviteStatus.invite_exists:
|
||||
case AccessInviteStatus.success:
|
||||
return exec.Result!;
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object AccountsAccessDelete([AsGuid] string id, [AsGuid] string userId)
|
||||
public ObjectResult AccountsAccessDelete([AsGuid] string id, [AsGuid] string userId)
|
||||
{
|
||||
var exec = _accountService.AccessDelete(UserId, id.AsGuid(), userId.AsGuid());
|
||||
|
||||
@@ -184,21 +183,21 @@ public class SettingsAccountController : BaseApiController
|
||||
return ProblemBadResponse("Account not found.");
|
||||
|
||||
case GeneralExecStatus.success:
|
||||
return exec.Result!;
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public List<AccountAccessInviteViewModel> AccountInvites()
|
||||
public ObjectResult AccountInvites()
|
||||
{
|
||||
var invites = _accountService.InvitesGet(_contextProvider.User.Email);
|
||||
|
||||
return _mapper.Map<List<AccountAccessInviteViewModel>>(invites);
|
||||
return OkResponse(_mapper.Map<List<AccountAccessInviteViewModel>>(invites));
|
||||
}
|
||||
|
||||
public object AccountInviteAccept([AsGuid] string id, AccountInviteAcceptRequest request)
|
||||
public ObjectResult AccountInviteAccept([AsGuid] string id, AccountInviteAcceptRequest request)
|
||||
{
|
||||
var exec = _accountService.InviteAccept(UserId, id.AsGuid(), request.Name);
|
||||
|
||||
@@ -211,14 +210,14 @@ public class SettingsAccountController : BaseApiController
|
||||
|
||||
case InviteAcceptStatus.already_accepted:
|
||||
case InviteAcceptStatus.success:
|
||||
return _mapper.Map<AccountViewModel>(exec.Result!);
|
||||
return OkResponse(_mapper.Map<AccountViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
public object AccountInviteReject([AsGuid] string id)
|
||||
public ObjectResult AccountInviteReject([AsGuid] string id)
|
||||
{
|
||||
var exec = _accountService.InviteReject(id.AsGuid());
|
||||
|
||||
@@ -229,7 +228,7 @@ public class SettingsAccountController : BaseApiController
|
||||
return ProblemBadResponse("Invite not found.");
|
||||
|
||||
case GeneralExecStatus.success:
|
||||
return _mapper.Map<AccountAccessInviteViewModel>(exec.Result!);
|
||||
return OkResponse(_mapper.Map<AccountAccessInviteViewModel>(exec.Result!));
|
||||
|
||||
default:
|
||||
throw new NotSupportedException(exec.Status.ToString());
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
namespace MyOffice.Web.Infrastructure.Attributes;
|
||||
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ApplicationModels;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
@@ -17,10 +18,15 @@ public class DefaultFromBodyBindingConvention : IActionModelConvention
|
||||
throw new ArgumentNullException(nameof(action));
|
||||
}
|
||||
|
||||
if (action.Controller.Attributes.Any(a => a is DefaultFromBodyAttribute))
|
||||
if (action.Controller.Attributes.Any(x => x is DefaultFromBodyAttribute))
|
||||
{
|
||||
foreach (var parameter in action.Parameters)
|
||||
{
|
||||
if (parameter.Attributes.Any(x => x is FromQueryAttribute))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var paramType = parameter.ParameterInfo.ParameterType;
|
||||
var isSimpleType = paramType.IsPrimitive
|
||||
|| paramType.IsEnum
|
||||
@@ -28,6 +34,7 @@ public class DefaultFromBodyBindingConvention : IActionModelConvention
|
||||
|| paramType == typeof(int)
|
||||
|| paramType == typeof(Guid)
|
||||
|| paramType == typeof(DateTime)
|
||||
|| paramType == typeof(DateTime?)
|
||||
|| paramType == typeof(decimal);
|
||||
|
||||
if (!isSimpleType)
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
using AutoMapper;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
|
||||
public class AccountAccessInviteViewModel
|
||||
public class AccountAccessInviteViewModel: IResponseModel
|
||||
{
|
||||
public string? Id { get; set; }
|
||||
public string? Account { get; set; }
|
||||
|
||||
@@ -18,6 +18,10 @@ public class MotionViewModelProfile : Profile
|
||||
{
|
||||
public MotionViewModelProfile()
|
||||
{
|
||||
CreateMap<MotionDto, MotionViewModel>();
|
||||
CreateMap<MotionDto, MotionViewModel>()
|
||||
.ForMember(x => x.Item, x => x.MapFrom(m => m.Item.Name))
|
||||
.ForMember(x => x.Minus, x => x.MapFrom(m => m.AmountMinus))
|
||||
.ForMember(x => x.Plus, x => x.MapFrom(m => m.AmountPlus))
|
||||
;
|
||||
}
|
||||
}
|
||||
@@ -74,8 +74,6 @@ using MyOffice.Web.Infrastructure.Filters;
|
||||
//TODO: SPA all http requests -> services
|
||||
//TODO: Items, select category -> save url to allow refresh
|
||||
//TODO: Accounts, select category -> save url to allow refresh
|
||||
//TODO: report income
|
||||
//TODO: report outcome
|
||||
|
||||
public partial class Program
|
||||
{
|
||||
@@ -160,10 +158,6 @@ public partial class Program
|
||||
options.JsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
|
||||
});
|
||||
|
||||
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
|
||||
//builder.Services.AddEndpointsApiExplorer();
|
||||
//builder.Services.AddSwaggerGen();
|
||||
|
||||
builder.Services.AddCors();
|
||||
|
||||
builder.Services.AddControllersWithViews(options =>
|
||||
@@ -306,6 +300,9 @@ public partial class Program
|
||||
builder.Services.AddScoped<IItemRepository, ItemRepository>();
|
||||
builder.Services.AddScoped<IItemGlobalRepository, ItemGlobalRepository>();
|
||||
builder.Services.AddScoped<IMotionRepository, MotionRepository>();
|
||||
|
||||
builder.Services.AddScoped<IVerificationCodeRepository, VerificationCodeRepository>();
|
||||
builder.Services.AddScoped<IEmailTemplateRepository, EmailTemplateRepository>();
|
||||
}
|
||||
|
||||
private static void AddBusinessServices(WebApplicationBuilder builder)
|
||||
|
||||
Reference in New Issue
Block a user