This commit is contained in:
he
2023-05-18 15:46:13 +08:00
parent 73035a4369
commit 1461240f27
4 changed files with 15 additions and 0 deletions
@@ -8,6 +8,8 @@ using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Application.Interfaces;
using IRaCIS.Core.Application.ViewModel;
using IRaCIS.Core.Infrastructure;
namespace IRaCIS.Core.Application.Service
{
/// <summary>
@@ -49,6 +51,15 @@ namespace IRaCIS.Core.Application.Service
public async Task<IResponseOutput> AddOrUpdateUserWLTemplate(UserWLTemplateAddOrEdit addOrEditUserWLTemplate)
{
addOrEditUserWLTemplate.UserId = _userInfo.Id;
if (addOrEditUserWLTemplate.Id == null)
{
var count = await _userWLTemplateRepository.Where(x => x.UserId == _userInfo.Id).CountAsync();
if (count >= 10)
{
throw new BusinessValidationFailedException(_localizer["UserWLTS_MaxTemplate"]);
}
}
var entity = await _userWLTemplateRepository.InsertOrUpdateAsync(addOrEditUserWLTemplate, true);
return ResponseOutput.Ok(entity.Id.ToString());
}