public async Task <IActionResult> UpdateYachtCharteringSchedulesAsync([FromBody] YachtCharteringSchedulesUpdateModel model) { var result = await _yachtCharteringSchedulesService.UpdateYachtCharteringSchedules(model); if (result.IsSuccessStatusCode) { return(Ok(result)); } return(BadRequest()); }
public async Task <BaseResponse <bool> > UpdateYachtCharteringSchedules(YachtCharteringSchedulesUpdateModel model) { try { var check = CheckDate(model.EffectiveStartDate, model.EffectiveEndDate); if (check) { return(BaseResponse <bool> .BadRequest()); } var entity = _context.YachtCharteringSchedules.Find(model.Id); if (entity != null) { entity.InjectFrom(model); entity.LastModifiedBy = GetUserGuidId(); entity.LastModifiedDate = DateTime.Now; // Set Role resourse if (model.RoleFid == (int)MerchantUserRoleEnum.MasterAccount) { entity.RoleResKey = "ROLEMASTER"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.Manager) { entity.RoleResKey = "ROLEMANAGER"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.Executive) { entity.RoleResKey = "ROLEEXECUTIVE"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.ServiceExecutive) { entity.RoleResKey = "ROLESERVICEEXECUTIVE"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.Captain) { entity.RoleResKey = "ROLECAPTAIN"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.Chef) { entity.RoleResKey = "ROLECHEF"; } else if (model.RoleFid == (int)MerchantUserRoleEnum.CrewMember) { entity.RoleResKey = "ROLEMEMBER"; } else { entity.RoleResKey = "UNKNOWN"; } _context.YachtCharteringSchedules.Update(entity); await _context.SaveChangesAsync(); return(BaseResponse <bool> .Success(true)); } else { return(BaseResponse <bool> .NotFound()); } } catch (Exception ex) { return(BaseResponse <bool> .InternalServerError(message : ex.Message)); } }