public async Task <IActionResult> CreateSecondStep(HallCreateViewModel model, CancellationToken token, string returnUrl = null) { AddBreadcrumb("Halls", "/Hall/All"); AddBreadcrumb("Create", "/Hall/Create"); model.ActiveTab = 2; if (ModelState.IsValid) { var array = JsonConvert.DeserializeObject <bool[, ]>(model.HallTableJson); var seats = array.Cast <bool>().Count(seat => seat); var hall = new Hall { Name = model.Name, Rows = array.GetLength(0), Columns = array.GetLength(1), Is3D = model.Is3D, IsImax = model.IsIMAX, Seats = seats, HallTableJson = model.HallTableJson, Cinema = await _cinemaRepository.FindByIdAsync(long.Parse(model.SelectedCinema), token) }; await _hallRepository.AddAsync(hall, token); return(RedirectToAction(nameof(All), "Hall")); } return(View("Create", model)); }
public IActionResult Create() { HallCreateViewModel model = new HallCreateViewModel { Halls = _hallService.GetActiveHalls() }; return(View(model)); }
public async Task <IActionResult> Delete(HallCreateViewModel model) { if (model.ID != null) { _hallService.DeleteHall(model.ID); } return(RedirectToAction(nameof(Create), "Hall")); }
public async Task <IActionResult> CreateFirstStep(HallCreateViewModel model, CancellationToken token, string returnUrl = null) { AddBreadcrumb("Halls", "/Hall/All"); AddBreadcrumb("Create", "/Hall/Create"); model.ActiveTab = 1; if (ModelState.IsValid) { model.ActiveTab = 2; return(View("Create", model)); } return(View("Create", model)); }
public async Task <IActionResult> Create(CancellationToken token) { AddBreadcrumb("Halls", "/Hall/All"); AddBreadcrumb("Create", "/Hall/Create"); var cinemas = await GetCinemas(token); var viewModel = new HallCreateViewModel { Cinemas = cinemas }; return(View(viewModel)); }
public async Task <IActionResult> Create(HallCreateViewModel model) { // Checks if string is empty and checks if RouteType is less or equal to the max value of the enum RouteType if (!string.IsNullOrEmpty(model.Name) && ((int)model.Type <= Enum.GetValues(typeof(RouteType)) .Cast <RouteType>() .Distinct() .Count())) { _hallService.AddHall(model.Name, model.Type); } return(RedirectToAction(nameof(Create), "Hall")); }
public async Task Create_RouteTypeInvalidInput_RedirectToActionCreateHall() { // Arrange var mockService = new Mock <IHallService>(); HallController controller = new HallController(mockService.Object); var hallListViewModel = new HallCreateViewModel { Name = "boulder", Type = (RouteType)4 }; // Act var result = await controller.Create(hallListViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Hall", redirectToActionResult.ControllerName); Assert.Equal("Create", redirectToActionResult.ActionName); mockService.Verify(service => service.AddHall(It.IsAny <string>(), It.IsAny <RouteType>()), Times.Never); }
public async Task Delete_InvalidNullAsId_RedirectToActionCreateHall() { // Arrange var mockService = new Mock <IHallService>(); HallController controller = new HallController(mockService.Object); var hallCreateViewModel = new HallCreateViewModel { ID = null }; // Act var result = await controller.Delete(hallCreateViewModel); // Assert var redirectToActionResult = Assert.IsType <RedirectToActionResult>(result); Assert.Equal("Hall", redirectToActionResult.ControllerName); Assert.Equal("Create", redirectToActionResult.ActionName); mockService.Verify(service => service.DeleteHall(It.IsAny <int?>()), Times.Never); }