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)); } }
private IEnumerable <SelectListItem> MakeCustomersDropDownList(Guid?customerId = null) { var customers = RestIntegration.Get <ApiReturnList <CustomerResult> >("http://localhost:54878/", "/api/Customers"); return(customers?.Items.Select(s => new SelectListItem { Text = s.Name, Selected = customerId.HasValue && s.CustomerId == customerId, Value = s.CustomerId.ToString() })); }
private IEnumerable <SelectListItem> MakeServicesDropDownList(Guid?serviceId = null) { var services = RestIntegration.Get <ApiReturnList <ServiceResult> >("http://localhost:54878/", "/api/Services"); ViewBag.EntityServices = services?.Items ?? new List <ServiceResult>(); return(services?.Items.Select(s => new SelectListItem { Text = s.Name, Selected = serviceId.HasValue && s.ServiceId == serviceId, Value = s.ServiceId.ToString() })); }
// GET: Schedules/Edit/5 public ActionResult Edit(Guid id) { var schedule = RestIntegration.Get <ApiReturnItem <ScheduleResult> >("http://localhost:54878/", $"/api/Schedules/{id}"); MakeDropdownsViewbags(schedule?.Item?.Hour, schedule?.Item?.Customer?.CustomerId, schedule?.Item?.Service?.ServiceId); var model = schedule?.Item; return(View(new ScheduleViewModel { Day = model.Day, Hour = model.Hour, ScheduleId = model.ScheduleId, ServiceId = model.ServiceId, CustomerId = model.CustomerId, Customer = model.Customer, Service = model.Service })); }
// GET: Schedules public ActionResult Index() { var Schedules = RestIntegration.Get <ApiReturnList <ScheduleResult> >("http://localhost:54878/", "/api/Schedules"); return(View(Schedules?.Items)); }
// GET: Services/Edit/5 public ActionResult Edit(Guid id) { var Service = RestIntegration.Get <ApiReturnItem <ServiceResult> >("http://localhost:54878/", $"/api/Services/{id}"); return(View(Service?.Item)); }
// GET: Customers/Edit/5 public ActionResult Edit(Guid id) { var customer = RestIntegration.Get <ApiReturnItem <CustomerResult> >("http://localhost:54878/", $"/api/Customers/{id}"); return(View(customer?.Item)); }
// GET: Customers public ActionResult Index() { var customers = RestIntegration.Get <ApiReturnList <CustomerResult> >("http://localhost:54878/", "/api/Customers"); return(View(customers?.Items)); }