fix
This commit is contained in:
@@ -1,20 +1,19 @@
|
||||
namespace MyOffice.Services.Account
|
||||
{
|
||||
using AutoMapper;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using Identity;
|
||||
using Core;
|
||||
using Core.Extensions;
|
||||
using Core.Helpers;
|
||||
using Data.Models.Accounts;
|
||||
using Data.Models.Items;
|
||||
using Data.Repositories.Account;
|
||||
using Data.Repositories.Currency;
|
||||
using Data.Repositories.Item;
|
||||
using Domain;
|
||||
using Item;
|
||||
using Item.Domain;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using MyOffice.Services.Account.Domain;
|
||||
using System.Collections.Generic;
|
||||
using Identity;
|
||||
|
||||
public class AccountService
|
||||
{
|
||||
@@ -84,15 +83,19 @@
|
||||
return result.Set(_mapper.Map<AccountCategoryDto>(category));
|
||||
}
|
||||
|
||||
public Exec<AccountCategoryDto, GeneralExecStatus> CategoryAdd(Guid userId, AccountCategory category)
|
||||
public Exec<AccountCategoryDto, GeneralExecStatus> CategoryAdd(Guid userId, AccountCategoryDto input)
|
||||
{
|
||||
if (category == null)
|
||||
throw new ArgumentNullException(nameof(category));
|
||||
if (input == null)
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
|
||||
var result = new Exec<AccountCategoryDto, GeneralExecStatus>(GeneralExecStatus.success);
|
||||
|
||||
category.Id = Guid.NewGuid();
|
||||
category.UserId = userId;
|
||||
var category = new AccountCategory
|
||||
{
|
||||
Id = Guid.NewGuid(),
|
||||
UserId = userId,
|
||||
Name = input.Name,
|
||||
};
|
||||
|
||||
if (!_accountCategoryRepository.Add(category))
|
||||
{
|
||||
@@ -102,10 +105,10 @@
|
||||
return result.Set(_mapper.Map<AccountCategoryDto>(category));
|
||||
}
|
||||
|
||||
public Exec<AccountCategoryDto, GeneralExecStatus> CategoryUpdate(Guid userId, Guid id, AccountCategory category)
|
||||
public Exec<AccountCategoryDto, GeneralExecStatus> CategoryUpdate(Guid userId, Guid id, AccountCategoryDto input)
|
||||
{
|
||||
if (category == null)
|
||||
throw new ArgumentNullException(nameof(category));
|
||||
if (input == null)
|
||||
throw new ArgumentNullException(nameof(input));
|
||||
|
||||
var result = new Exec<AccountCategoryDto, GeneralExecStatus>(GeneralExecStatus.success);
|
||||
|
||||
@@ -115,7 +118,7 @@
|
||||
return result.Set(GeneralExecStatus.not_found);
|
||||
}
|
||||
|
||||
exists.Name = category.Name;
|
||||
exists.Name = input.Name;
|
||||
|
||||
if (!_accountCategoryRepository.Update(exists))
|
||||
{
|
||||
@@ -300,14 +303,11 @@
|
||||
|
||||
if (category != null && account.Categories!.All(x => x.CategoryId != category.Id))
|
||||
{
|
||||
account.Categories = new List<AccountAccountCategory>
|
||||
_accountAccountCategoryRepository.Add(new AccountAccountCategory
|
||||
{
|
||||
new()
|
||||
{
|
||||
AccountId = account.Id,
|
||||
CategoryId = category.Id,
|
||||
}
|
||||
};
|
||||
AccountId = account.Id,
|
||||
CategoryId = category.Id,
|
||||
});
|
||||
}
|
||||
|
||||
if (!_accountRepository.Update(account))
|
||||
@@ -346,7 +346,7 @@
|
||||
return result.Set(categories);
|
||||
}
|
||||
|
||||
public Exec<List<Motion>, MotionAddStatus> MotionAdd(
|
||||
public Exec<List<MotionDto>, MotionAddStatus> MotionAdd(
|
||||
Guid userId,
|
||||
Guid accountId,
|
||||
MotionAddUpdate motion
|
||||
@@ -357,7 +357,7 @@
|
||||
if (motion.Item == null)
|
||||
throw new ArgumentNullException(nameof(motion.Item));
|
||||
|
||||
var result = new Exec<List<Motion>, MotionAddStatus>(MotionAddStatus.success);
|
||||
var result = new Exec<List<MotionDto>, MotionAddStatus>(MotionAddStatus.success);
|
||||
|
||||
var account = _accountRepository.Get(userId, accountId);
|
||||
if (account == null)
|
||||
@@ -388,8 +388,8 @@
|
||||
return result.Set(MotionAddStatus.failure);
|
||||
}
|
||||
|
||||
result.Set(new List<Motion>());
|
||||
result.Result!.Add(motionDb);
|
||||
result.Set(new List<MotionDto>());
|
||||
result.Result!.Add(_mapper.Map<MotionDto>(motionDb));
|
||||
|
||||
if (motion.AccountId.IsPresent() && motion.AmountBalancing != 0)
|
||||
{
|
||||
@@ -419,7 +419,7 @@
|
||||
|
||||
if (_motionRepository.Add(motionBalancing))
|
||||
{
|
||||
result.Result!.Add(motionBalancing);
|
||||
result.Result!.Add(_mapper.Map<MotionDto>(motionBalancing));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -429,7 +429,7 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
public Exec<Motion, MotionUpdateStatus> MotionUpdate(
|
||||
public Exec<MotionDto, MotionUpdateStatus> MotionUpdate(
|
||||
Guid userId,
|
||||
Guid accountId,
|
||||
Guid motionId,
|
||||
@@ -441,7 +441,7 @@
|
||||
if (motion.Item == null)
|
||||
throw new ArgumentNullException(nameof(motion.Item));
|
||||
|
||||
var result = new Exec<Motion, MotionUpdateStatus>(MotionUpdateStatus.success);
|
||||
var result = new Exec<MotionDto, MotionUpdateStatus>(MotionUpdateStatus.success);
|
||||
|
||||
var exists = _motionRepository.Get(userId, motionId);
|
||||
if (exists == null || exists.AccountId != accountId)
|
||||
@@ -467,7 +467,7 @@
|
||||
|
||||
}
|
||||
|
||||
return result.Set(exists);
|
||||
return result.Set(_mapper.Map<MotionDto>(exists));
|
||||
}
|
||||
|
||||
public Exec<List<Motion>, GeneralExecStatus> GetMotions(
|
||||
|
||||
Reference in New Issue
Block a user