private void buttonAdd_Click(object sender, EventArgs e)
 {
     if (ValidationService.ValidateIsNumber(textBoxNumber.Text) && ValidationService.ValidateIsNumber(textBoxCapability.Text) &&
         ValidationService.ValidateIsPrice(textBoxPrice.Text))
     {
         var newRoom = new Room()
         {
             Number       = Convert.ToInt32(textBoxNumber.Text),
             Price        = Convert.ToDouble(textBoxPrice.Text),
             Capability   = Convert.ToInt16(textBoxCapability.Text),
             ComfortLevel = Convert.ToInt16(comboBoxComfortLvl.Text),
             HotelId      = Convert.ToInt32(hotelId.ToString()),
             Created      = DateTime.Now
         };
         using (var context = ContextResolver.GetContext(connectionString))
         {
             var roomService = new RoomService(context);
             roomService.Add(newRoom);
         }
         MessageBox.Show("New record has added");
         this.Close();
     }
     else
     {
         labelValidationMessage.Visible = true;
     }
 }
Esempio n. 2
0
        public void CreateNewRoomTest()
        {
            Room newRoom = new Room(0, "test room", "een room om de functie te testen");

            _RoomService.Add(newRoom);

            Assert.Fail();
        }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,RoomNumber,RoomType,TV,HotWater,Towel,IsAvailable,Price")] RoomModel roomModel)
        {
            if (ModelState.IsValid)
            {
                _roomService.Add(roomModel);
                return(RedirectToAction("Index"));
            }

            return(View(roomModel));
        }
 public IActionResult Post([FromBody] AddRoomModel model)
 {
     if (ModelState.IsValid)
     {
         var room = _roomService.Add(new Room()
         {
             Name = model.Name
         });
         return(Created(Url.Action(nameof(Get), new { room.Id }), room));
     }
     return(BadRequest());
 }
Esempio n. 5
0
        public ActionResult Create(Room room)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    roomService.Add(room);

                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException)
            {
                ModelState.AddModelError("", "Không thể tạo phòng chiếu!");
            }
            return(View(room));
        }
Esempio n. 6
0
        public Room Add(Room room)
        {
            return(Execute(session =>
            {
                var numbers = room.RoomNumber.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var number in numbers)
                {
                    var r = new Room
                    {
                        HouseId = room.HouseId,
                        Id = room.Id,
                        RoomNumber = number,
                        RoomType = room.RoomType
                    };
                    RoomService.Add(r);
                }

                return new Room();
            }));
        }
Esempio n. 7
0
 public Room Add(Room room)
 {
     return(_roomService.Add(room));
 }
        public CreatedRoom AddRoom(RoomCreation values)
        {
            var createdRoom = roomService.Add(values.RoomName, this.userService.Get(values.UserId), this.deckService.Get(values.DeckId));

            return(new CreatedRoom(createdRoom.Id, createdRoom.Name));
        }