public IHttpActionResult UpdateShiftProfile(ShiftProfileModel shiftProfileModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { //var shiftProfileDto = Mapper.Map<ShiftProfileDto>(shiftProfileModel); var shiftProfileDto = _shiftProfileAppService.GetById(shiftProfileModel.Id); shiftProfileDto.Reason = shiftProfileModel.Reason; shiftProfileDto.Notes = shiftProfileModel.Notes; shiftProfileDto.ActualStartDateTime = shiftProfileModel.ActualStartDateTime; shiftProfileDto.ActualEndDateTime = shiftProfileModel.ActualEndDateTime; shiftProfileDto.IsApproved = shiftProfileModel.IsApproved; shiftProfileDto.IsModified = shiftProfileModel.IsModified; shiftProfileDto.HoursWorked = CommonHelperAppService.ReturnCalculatedTimespanBetweenTwoDateTimeObjects( shiftProfileDto.ActualStartDateTime, shiftProfileDto.ActualEndDateTime, 0); _shiftProfileAppService.Update(shiftProfileDto, AuthHelper.GetCurrentUserId()); return(Ok("Shift Profile Updated")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }
public IHttpActionResult UpdateFormAndShiftProfile(TimeAdjustmentFormAndShiftProfileUpdateModel model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { // TAF var tafDto = _timeAdjustmentFormAppService.GetById(model.TimeAdjustmentFormId); tafDto.IsManagerApproved = model.IsManagerApproved; tafDto.IsAdminApproved = model.IsAdminApproved; _timeAdjustmentFormAppService.Update(tafDto, AuthHelper.GetCurrentUserId()); // Shift Profile var shiftProfileDto = _shiftProfileAppService.GetById(model.ShiftProfileId); shiftProfileDto.Reason = model.Reason; shiftProfileDto.Notes = model.Notes; if (model.IsAdminApproved) { shiftProfileDto.IsApproved = true; shiftProfileDto.ActualStartDateTime = model.ActualStartDateTime; shiftProfileDto.ActualEndDateTime = model.ActualEndDateTime; shiftProfileDto.HoursWorked = CommonHelperAppService.ReturnCalculatedTimespanBetweenTwoDateTimeObjects( shiftProfileDto.ActualStartDateTime, shiftProfileDto.ActualEndDateTime, 0); } _shiftProfileAppService.Update(shiftProfileDto, AuthHelper.GetCurrentUserId()); return(Ok("Success.")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }