Beispiel #1
0
 public static Hall GetHallByName(string name)
 {
     try
     {
         return(HallController.GetByName(name));
     }
     catch (Exception e)
     {
         return(new Hall());
     }
 }
Beispiel #2
0
 public static Hall GetHallById(int id)
 {
     try
     {
         return(HallController.Get(id));
     }
     catch (Exception e)
     {
         return(new Hall());
     }
 }
Beispiel #3
0
 public static List <Hall> GetAllHalls()
 {
     try
     {
         return(HallController.All());
     }
     catch (Exception e)
     {
         return(new List <Hall>());
     }
 }
Beispiel #4
0
 public static bool HallDeleteValidation(int id)
 {
     try
     {
         HallController.Delete(id);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Beispiel #5
0
 public static bool HallUpdateValidation(int id, string name)
 {
     try
     {
         HallController.Update(id, name);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Beispiel #6
0
 public static bool HallAddValidation(string name)
 {
     try
     {
         if (name == null || GetHallByName(name).Name != null)
         {
             return(false);
         }
         HallController.Add(name);
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Beispiel #7
0
        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);
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        public void List_RouteHall_ReturnViewModel()
        {
            // Arrange
            var mockService = new Mock <IHallService>();

            mockService.Setup(service => service.GetActiveHalls())
            .Returns(new List <RouteHall> {
                new RouteHall(), new RouteHall()
            });

            HallController controller = new HallController(mockService.Object);

            // Act
            var result = controller.Create();

            // Assert
            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <HallCreateViewModel>(
                viewResult.ViewData.Model);

            Assert.Equal(2, model.Halls.Count);
        }
 public void Init()
 {
     hall = new HallController();
 }