public async Task<ResponseBool> ShiftSaveAsync(Shift shift) { ResponseBool _response = new ResponseBool { Success = false, ErrorInfo = "" }; var dto = _masterDataToDTOMapping.Map(shift); if (dto == null) return _response; string url = string.Format("api/pushmasterdata/shift/save"); var httpClient = setupHttpClient(); httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); try { var response = await httpClient.PostAsJsonAsync(url, dto); _response = await response.Content.ReadAsAsync<ResponseBool>(); } catch (Exception ex) { _response.ErrorInfo = "Failed to save shift DTO.\n" + ex.Message; _log.Error("Failed to save shift DTO", ex); } return _response; }
public ShiftDTO Map(Shift shiftEntity) { if (shiftEntity == null) return null; var shiftDto = Mapper.Map<Shift, ShiftDTO>(shiftEntity); return shiftDto; }
protected Guid AddShift(string name, string code, string description, DateTime startTime, DateTime endTime) { var shift = new Shift(Guid.NewGuid()) { Name = name, Code = code, StartTime = startTime, EndTime = endTime, Description = description }; shift._SetStatus(EntityStatus.Active); return _ShiftRepository.Save(shift); }