public async Task <HttpResponseMessage> Update(HttpRequestMessage request, EntitleDay_AppUserModel entitleDay_AppUserModel) { return(await CreateHttpResponse(request, () => { HttpResponseMessage response = null; if (!ModelState.IsValid) { response = request.CreateResponse(HttpStatusCode.BadRequest, ModelState); } else { var dbEntitleDay = _entitleDayAppUserService.GetById(entitleDay_AppUserModel.EntitleDayAppUserId); //if (entitleDay_AppUserModel.MaxEntitleDay == dbEntitleDay.MaxEntitleDayAppUser) //{ dbEntitleDay.UpdateEntitleDayAppUser(entitleDay_AppUserModel); if (entitleDay_AppUserModel.NumberDayOff > entitleDay_AppUserModel.MaxEntitleDay) { return request.CreateResponse(HttpStatusCode.BadRequest, Common.Constants.MessageSystem.MaxEntitleDayNumberDay_Error); } else if (entitleDay_AppUserModel.UnitType.Equals(CommonConstants.DayPeriod)) { return request.CreateResponse(HttpStatusCode.BadRequest, Common.Constants.MessageSystem.MaxEntitleDayNumberDay_Error); } else { if (entitleDay_AppUserModel.NumberDayOff % CommonConstants.ZERO_PONT_FIVE == (CommonConstants.ZERO)) { _entitleDayAppUserService.UpdateEntitleDayAppUser(dbEntitleDay); response = request.CreateResponse(HttpStatusCode.Created, dbEntitleDay); } else { return request.CreateResponse(HttpStatusCode.BadRequest, Common.Constants.MessageSystem.NumberDayOff_Error); } //} } } return response; })); }
public static void UpdateEntitleDayAppUser(this Entitleday_AppUser entitleday_AppUser, EntitleDay_AppUserModel entitleDay_AppUserModel) { entitleday_AppUser.ID = entitleDay_AppUserModel.EntitleDayAppUserId; entitleday_AppUser.MaxEntitleDayAppUser = entitleDay_AppUserModel.MaxEntitleDay; entitleday_AppUser.NumberDayOff = entitleDay_AppUserModel.NumberDayOff; entitleday_AppUser.Note = entitleDay_AppUserModel.Note; }