Beispiel #1
0
        public IActionResult Edit(int id, HallsFormServiceModel hallsFormModel)
        {
            bool hallExists = this.hallsAdminService.Exists(id);

            if (!hallExists)
            {
                return(RedirectToAction(nameof(Index)));
            }

            if (!ModelState.IsValid)
            {
                return(View(hallsFormModel));
            }

            this.hallsAdminService.Edit(id, hallsFormModel.Name,
                                        hallsFormModel.HallCapacity,
                                        hallsFormModel.MondayFriday8amTo3pm,
                                        hallsFormModel.MondayThursday4pmToMN,
                                        hallsFormModel.Friday4pmToMN,
                                        hallsFormModel.Saturday8amTo3pm,
                                        hallsFormModel.Saturday4pmToMN,
                                        hallsFormModel.Sunday8amTo3pm,
                                        hallsFormModel.Sunday4pmToMN,
                                        hallsFormModel.TablesAndChairsCostPerPerson,
                                        hallsFormModel.SecurityGuardCostPerHour,
                                        hallsFormModel.SecurityDepositBefore10pm,
                                        hallsFormModel.SecurityDepositAfter10pm);

            TempData.AddSuccessMessage($"Hall {hallsFormModel.Name} has been edited");

            return(RedirectToAction(nameof(Index)));
        }
Beispiel #2
0
        public IActionResult Edit(int id)
        {
            bool hallExists = this.hallsAdminService.Exists(id);

            if (!hallExists)
            {
                return(RedirectToAction(nameof(Index)));
            }

            HallsFormServiceModel currentHall = this.hallsAdminService.GetFormModelById(id);

            if (currentHall == null)
            {
                return(NotFound());
            }

            return(View(currentHall));
        }