Beispiel #1
0
        public void RoomTypeService_Can_Create_Room()
        {
            //Arrange
            var roomType = new RoomType
            {
                Name = "NewRoomType"
            };

            _unitOfWork.Setup(m => m.RoomTypes.Create(roomType));
            // Act
            _roomTypeServices.Create(roomType);
            // Assert
            _unitOfWork.Verify(v => v.RoomTypes.Create(roomType), Times.Once());
            _unitOfWork.Verify(x => x.Save(), Times.Once());
        }
Beispiel #2
0
        public ActionResult CreateRoomType(RoomTypeViewModel roomTypeViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var roomType = new RoomType
                    {
                        Name = roomTypeViewModel.Name
                    };
                    Logger.Log.Debug("Add new room type");
                    _roomType.Create(roomType);
                    return(RedirectToAction("RoomTypeList"));
                }
            }
            catch (Exception ex)
            {
                Logger.Log.Error("Error adding new room type", ex);
                ModelState.AddModelError("", ex.Message);
            }

            return(RedirectToAction("RoomTypeList"));
        }