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; } }
public void CreateNewRoomTest() { Room newRoom = new Room(0, "test room", "een room om de functie te testen"); _RoomService.Add(newRoom); Assert.Fail(); }
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()); }
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)); }
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(); })); }
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)); }