/// <summary> /// Updates the modifier. /// </summary> /// <param name="modifierDto">The modifier dto.</param> /// <returns></returns> public async Task <(bool Response, string Message)> UpdateAsync(ModifierDto modifierDto) { bool response = false; string message = string.Empty; if (null != modifierDto) { var existisModifier = await GetByCodeAsync(modifierDto.Modifier_code.Trim()); if (existisModifier != null && existisModifier.Procedure_Modifier_Id != modifierDto.Modifier_id) { message = "The code entered is a duplicate."; } else { var obj_C_PROCEDURE_MODIFIER = await MidUnit.GetRepository <C_PROCEDURE_MODIFIER>() .GetByIdAsync(modifierDto.Modifier_id); if (obj_C_PROCEDURE_MODIFIER == null) { message = Enums.ErrorCode.ObjectNotFound.ToString(); } else { obj_C_PROCEDURE_MODIFIER.Updated_By = UserId.ToString(); obj_C_PROCEDURE_MODIFIER.Updated_Date = DateTime.Now; obj_C_PROCEDURE_MODIFIER.Proc_Mod_Code = modifierDto.Modifier_code.Trim(); obj_C_PROCEDURE_MODIFIER.Proc_Mod_Desc = modifierDto.Modifier_desc.Trim(); obj_C_PROCEDURE_MODIFIER.Is_Active = modifierDto.Is_active; MidUnit.GetRepository <C_PROCEDURE_MODIFIER>().Update(obj_C_PROCEDURE_MODIFIER); response = await MidUnit.CommitAsync(); } } } return(response, message); }
/// <summary> /// Adds the modifier. /// </summary> /// <param name="modifierDto">The modifier dto.</param> /// <returns></returns> public async Task <(int Id, string Message)> AddAsync(ModifierDto modifierDto) { int rowId = 0; string message = string.Empty; if (null != modifierDto) { var existisModifier = await GetByCodeAsync(modifierDto.Modifier_code.Trim()); if (existisModifier != null) { message = "The code entered is a duplicate."; } else { var obj_C_PROCEDURE_MODIFIER = new C_PROCEDURE_MODIFIER(); obj_C_PROCEDURE_MODIFIER.Company_Id = CompanyId; obj_C_PROCEDURE_MODIFIER.Created_By = UserId.ToString(); obj_C_PROCEDURE_MODIFIER.Created_Date = DateTime.Now; obj_C_PROCEDURE_MODIFIER.Updated_By = UserId.ToString(); obj_C_PROCEDURE_MODIFIER.Updated_Date = DateTime.Now; obj_C_PROCEDURE_MODIFIER.Proc_Mod_Code = modifierDto.Modifier_code.Trim(); obj_C_PROCEDURE_MODIFIER.Proc_Mod_Desc = modifierDto.Modifier_desc.Trim(); obj_C_PROCEDURE_MODIFIER.Is_Active = modifierDto.Is_active; obj_C_PROCEDURE_MODIFIER.avail_chg_capture = false; MidUnit.GetRepository <C_PROCEDURE_MODIFIER>() .Add(obj_C_PROCEDURE_MODIFIER); var saved = await MidUnit.CommitAsync(); rowId = saved ? obj_C_PROCEDURE_MODIFIER.Procedure_Modifier_Id : 0; } } return(rowId, message); }