/// <summary> /// Thêm mới SETTING /// </summary> /// <param name="input"></param> /// <param name="userId"></param> /// <returns></returns> public async Task <Tuple <AtSettingDmListOutput, AtNotify> > CreateSetting(AtSettingDmCreateInput input, string userId) { try { var checkIdSetting = await _context.Setting.AnyAsync(c => c.Id == input.Id); if (!checkIdSetting) { var model = new Setting { Id = input.Id, Value = input.Value, Description = input.Description, IdParent = input.IdParent }; var result = await _context.Setting.AddAsync(model); await _context.SaveChangesAsync(); var Output = _mapper.Map <AtSettingDmListOutput>(result.Entity); string data_Old = JsonConvert.SerializeObject(result.Entity); await WrtiteAudittingLog(new MSC_AudittingLog { Description = "Thêm mới Setting ", UserID = userId, Data_New = data_Old }, AtSerialNoConts.CODE_LOG_CREATE); return(new Tuple <AtSettingDmListOutput, AtNotify>(Output, AtNotify.InsertCompelete)); } else { return(new Tuple <AtSettingDmListOutput, AtNotify>(null, AtNotify.DuplicateCode)); } } catch (Exception ex) { throw ex; } }
public async Task <ActionResult <AtResult <AtSettingDmListOutput> > > CreateSetting([FromBody] AtSettingDmCreateInput input) { if (await CheckPermission(_context)) { try { var output = await _logicSetting.CreateSetting(input, UserId); if (output.Item2 == AtNotify.DuplicateCode) { return(new AtResult <AtSettingDmListOutput>(AtNotify.DuplicateCode)); } return(new AtResult <AtSettingDmListOutput>(output.Item1)); } catch (Exception ex) { throw ex; } } else { return(new AtResult <AtSettingDmListOutput>(AtNotify.KhongCoQuyenTruyCap)); } }