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 CreateShiftProfile(ShiftProfileModel shiftProfileModel) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { var shiftProfileDto = Mapper.Map <ShiftProfileDto>(shiftProfileModel); _shiftProfileAppService.Create(shiftProfileDto, AuthHelper.GetCurrentUserId()); // need to trip IsMatched flag on ZKT records _zktRecordAppService.SetIsMatched(shiftProfileModel.ZktStartDateTime, shiftProfileModel.ZktEndDateTime); return(Ok("Shift Profile Created")); } catch (Exception ex) { return(BadRequest(ex.Message)); } }