示例#1
0
        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));
            }
        }
示例#2
0
        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()
            }));
        }
示例#3
0
        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()
            }));
        }
示例#4
0
        // 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
            }));
        }
示例#5
0
        // GET: Schedules
        public ActionResult Index()
        {
            var Schedules = RestIntegration.Get <ApiReturnList <ScheduleResult> >("http://localhost:54878/", "/api/Schedules");

            return(View(Schedules?.Items));
        }
示例#6
0
        // 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));
        }
示例#7
0
        // 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));
        }
示例#8
0
        // GET: Customers
        public ActionResult Index()
        {
            var customers = RestIntegration.Get <ApiReturnList <CustomerResult> >("http://localhost:54878/", "/api/Customers");

            return(View(customers?.Items));
        }