Beispiel #1
0
        private void confirmBtn_Click(object sender, EventArgs e)
        {
            RoomServices roomServices = new RoomServices();

            label7.Text = "Status";
            updateBtn.Show();
            confirmBtn.Hide();
            Ward ward = new Ward();

            ward.Name = comboBox1.Text;
            int WardId = roomServices.GetWId(ward).Id;

            Room room = new Room();

            room.WId        = WardId;
            room.RoomNumber = Convert.ToInt32(textBox5.Text);
            room.Type       = comboBox2.Text;



            bool check = roomServices.Add(room);

            if (check)
            {
                MessageBox.Show("Added");
            }
            else
            {
                MessageBox.Show("Error !");
            }
        }
        public ActionResult Create(RoomViewModel model)
        {
            var res = new BaseResponse();

            if (string.IsNullOrEmpty(model?.Name) || string.IsNullOrEmpty(model.Description))
            {
                res.Msg = Constants.MsgFail;
                return(Json(res, JsonRequestBehavior.AllowGet));
            }

            try
            {
                var room = new Room
                {
                    Name        = model.Name,
                    Description = model.Description,
                    CreatedBy   = "Admin",
                    CreatedOn   = DateTime.Now,
                    UpdatedBy   = "Admin",
                    UpdatedOn   = DateTime.Now
                };

                RoomServices.Add(room);
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
            catch
            {
                res.Msg = Constants.MsgFail;
                return(Json(res, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #3
0
        public void Should_Display_One_More_Room_After_Adding_A_New_One()
        {
            var roomRepository  = RoomRepository.Instance;
            var bookingServices = new RoomServices(roomRepository);

            bookingServices.Add(new Room
            {
                Bookings = new List <Booking>(),
                Name     = "Room1",
                Number   = 1
            });

            List <Room> result = bookingServices.GetAll();

            Assert.AreEqual("Room1", result.First().Name);
        }