public BaseSingleResponse <CfgProvideHelpPolicyDto> Update(CfgProvideHelpPolicyDto dto) { var response = new BaseSingleResponse <CfgProvideHelpPolicyDto>(); try { var errors = Validate <CfgProvideHelpPolicyDto>(dto, new CfgProvideHelpPolicyValidator()); if (errors.Count() > 0) { return(new BaseSingleResponse <CfgProvideHelpPolicyDto>(dto, errors)); } var policy = _repository.Get(dto.Id); policy.Name = dto.Name; policy.Description = dto.Description; policy.ProfitRate = double.Parse(dto.ProfitRateTemp); policy.ProfitRate = double.Parse(dto.ProfitRateTemp); policy.NumberOfDays = int.Parse(dto.NumberOfDaysTemp); policy.ModifiedDate = DateTime.Now; _repository.SubmitChanges(); } catch (Exception ex) { response.IsSuccess = false; } return(response); }
public BaseSingleResponse <CfgProvideHelpPolicyDto> GetById(long id) { var response = new BaseSingleResponse <CfgProvideHelpPolicyDto>(); try { CfgProvideHelpPolicy policy = SingleById(id); if (policy != null) { CfgProvideHelpPolicyDto dto = MapperUtils.ConvertTo <CfgProvideHelpPolicy, CfgProvideHelpPolicyDto>(policy); dto.NumberOfDaysTemp = policy.NumberOfDays.ToString(); dto.ProfitRateTemp = policy.ProfitRate.ToString(); response.Value = dto; } } catch (Exception ex) { response.IsSuccess = false; } return(response); }