예제 #1
0
        public IActionResult ChangeService(ChangeServiceViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.ServicePackageSelected.Count() > 1)
                {
                    ModelState.AddModelError("ServicePackageSelected", "Select just one type of service!");

                    var serviceWrappersAtError = TempData.Get <List <ServiceWrapperViewModel> >("ServiceWrappers");
                    var viewModelAtError       = new ChangeServiceViewModel()
                    {
                        ServiceType     = model.ServiceType,
                        ServiceWrappers = serviceWrappersAtError
                    };
                    TempData.Put("ServiceWrappers", serviceWrappersAtError);
                    return(View(viewModelAtError));
                }
                var servicePackage = servicePackageService.GetById(model.ServicePackageSelected[0]);
                eventServiceService.UpdateServicePackage(model.EventServiceId, servicePackage.ServiceId, servicePackage.Id);
                return(RedirectToAction(nameof(MyEventsController.Index), "MyEvents"));
            }
            var serviceWrappers = TempData.Get <List <ServiceWrapperViewModel> >("ServiceWrappers");
            var viewModel       = new ChangeServiceViewModel()
            {
                ServiceType     = model.ServiceType,
                ServiceWrappers = serviceWrappers
            };

            TempData.Put("ServiceWrappers", serviceWrappers);
            return(View(viewModel));
        }
예제 #2
0
        public ChangeServiceWindow(object selectedItem)
        {
            InitializeComponent();
            var changeServiceViewModel = new ChangeServiceViewModel(selectedItem);

            changeServiceViewModel.CloseWindow = new Action(Close);
            DataContext = changeServiceViewModel;
        }
예제 #3
0
        public IActionResult ChangeService(int eventServiceId, ServiceType eventType, DateTime eventDate)
        {
            var eventService    = eventServiceService.GetById(eventServiceId);
            var serviceWrappers = GetServiceWrapperViewModels(eventDate, eventType.ToString(), 0, eventService.ServicePackageId);

            TempData.Put("ServiceWrappers", serviceWrappers);

            var viewModel = new ChangeServiceViewModel()
            {
                ServiceType     = eventType,
                ServiceWrappers = serviceWrappers
            };

            return(View(viewModel));
        }