예제 #1
0
 //    [AbpAuthorize("HR.Training.Operation")]
 public async Task CreateOrUpdate(ReplyUnitDto input)
 {
     if (input.Id.HasValue)
     {
         await UpdateAsync(input);
     }
     else
     {
         await CreateAsync(input);
     }
 }
예제 #2
0
        private async Task UpdateAsync(ReplyUnitDto input)
        {
            if (_replyUnitRepository.GetAll().Any(p => p.Name == input.Name && p.Id != input.Id.Value))
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该名称已经存在");
            }
            var model = await _replyUnitRepository.GetAsync(input.Id.Value);

            model.Name = input.Name;
            model.Sort = input.Sort;
            await _replyUnitRepository.UpdateAsync(model);
        }
예제 #3
0
        private async Task CreateAsync(ReplyUnitDto input)
        {
            if (_replyUnitRepository.GetAll().Any(p => p.Name == input.Name))
            {
                throw new UserFriendlyException((int)ErrorCode.DataAccessErr, "该名称已经存在");
            }
            var model = new ReplyUnit
            {
                Name = input.Name,
                Sort = input.Sort
            };
            await _replyUnitRepository.InsertAsync(model);

            await CurrentUnitOfWork.SaveChangesAsync(); //It's done to get Id of the edition.
        }