public ActionResult Edit(ScheduleViewModel model) { try { if (ModelState.IsValid) { var validate = RestIntegration.Get <ApiReturnItem <Boolean> >("http://localhost:54878/", $"/api/Schedules/Validate/{model.Day.Value:yyyy-MM-dd}/{model.Hour}/{model.ScheduleId}"); if (!(validate?.Item).GetValueOrDefault(false)) { var result = RestIntegration.Put <ScheduleRequest, ApiReturnList <ScheduleResult> >( "http://localhost:54878/", "/api/Schedules", new ScheduleRequest { Day = model.Day.Value, Hour = model.Hour.Value, ScheduleId = model.ScheduleId, ServiceId = model.ServiceId, CustomerId = model.CustomerId }); return(RedirectToAction(nameof(Index))); } ModelState.AddModelError(String.Empty, "Já existe agendamento no dia e horário escolhido"); } MakeDropdownsViewbags(model.Hour, model.CustomerId, model.ServiceId); return(View(model)); } catch (Exception e) { MakeDropdownsViewbags(model.Hour, model.CustomerId, model.ServiceId); return(View(model)); } }
public ActionResult Edit(ServiceResult model) { try { if (ModelState.IsValid) { var result = RestIntegration.Put <ServiceResult, ApiReturnList <ServiceResult> >("http://localhost:54878/", "/api/Services", model); return(RedirectToAction(nameof(Index))); } return(View(model)); } catch (Exception e) { return(View(model)); } }