Ejemplo n.º 1
0
        public void BookGuest(string firstName, string lastName, DateTime startDate, DateTime endDate, int roomTypeId)
        {
            // Insert to 'Guests' table and then retrieve that guest to eventually book them
            GuestModel guest = _db.LoadData <GuestModel, dynamic>("dbo.spGuests_Insert",
                                                                  new { firstName, lastName },
                                                                  connectionStringName,
                                                                  true).First();

            // To calculate total cost for the booking, need the room type and how many days were stayed
            RoomTypeModel roomType = _db.LoadData <RoomTypeModel, dynamic>("select * from dbo.RoomTypes where Id = @Id",
                                                                           new { Id = roomTypeId },
                                                                           connectionStringName,
                                                                           false).First();
            TimeSpan timeStaying = endDate.Date.Subtract(startDate.Date);

            // Get available rooms that fit the criteria of the dates desired and the room type
            List <RoomModel> availableRooms = _db.LoadData <RoomModel, dynamic>("dbo.spRooms_GetAvailableRooms",
                                                                                new { startDate, endDate, roomTypeId },
                                                                                connectionStringName,
                                                                                true);

            // Save booking by inserting into 'Bookings' table
            _db.SaveData("dbo.spBookings_Insert",
                         new
            {
                roomId  = availableRooms.First().Id,
                guestId = guest.Id,
                startDate,
                endDate,
                totalCost = timeStaying.Days * roomType.Price
            },
                         connectionStringName,
                         true);
        }
Ejemplo n.º 2
0
 public void OnGet()
 {
     if (RoomTypeId > 0)
     {
         RoomType = _db.GetRoomTypeById(RoomTypeId);
     }
 }
Ejemplo n.º 3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            RoomTypeModel model = new RoomTypeModel();
            RoomType      rt    = createRoomType();

            lblResult.Text = model.InsertRoomType(rt);
        }
Ejemplo n.º 4
0
        public string UpdateRoom(RoomTypeModel roomType)
        {
            string result = string.Empty;

            using (HotelDBContext _hotelEntities = new HotelDBContext())
            {
                try
                {
                    RoomType roomTbl = new RoomType();
                    roomTbl.Id         = roomType.Id;
                    roomTbl.RoomName   = roomType.RoomName;
                    roomTbl.Amenities  = roomType.Amenities;
                    roomTbl.ImagePath  = roomType.ImagePath;
                    roomTbl.ModifiedOn = System.DateTime.Now.ToShortDateString();
                    _hotelEntities.RoomTypes.Add(roomTbl);
                    _hotelEntities.Entry(roomTbl).State = System.Data.Entity.EntityState.Modified;
                    _hotelEntities.SaveChanges();
                    result = "Record Updated";
                }
                catch (Exception)
                {
                    result = "Failed To Upadate";
                }
                return(result);
            }
        }
Ejemplo n.º 5
0
        public void BookGuest(string firstName,
                              string lastName,
                              DateTime startDate,
                              DateTime endDate,
                              int roomTypeId)
        {
            GuestModel guest = _db.LoadData <GuestModel, dynamic>("dbo.spGuests_Insert",
                                                                  new { firstName, lastName },
                                                                  connectionStringName,
                                                                  true).First();
            RoomTypeModel roomType = _db.LoadData <RoomTypeModel, dynamic>("select * from dbo.RoomTypes where Id = @Id",
                                                                           new { Id = roomTypeId },
                                                                           connectionStringName,
                                                                           false).First();

            TimeSpan timeStaying = endDate.Date.Subtract(startDate.Date);

            List <RoomModel> availableRooms = _db.LoadData <RoomModel, dynamic>("dbo.spRooms_GetAvailableRooms",
                                                                                new { startDate, endDate, roomTypeId },
                                                                                connectionStringName,
                                                                                true);

            _db.SaveData("dbo.spBookings_insert",
                         new
            {
                roomId    = availableRooms.First().Id,
                guestId   = guest.Id,
                startDate = startDate,
                endDate   = endDate,
                totalCost = timeStaying.Days * roomType.Price
            },
                         connectionStringName,
                         true);
        }
Ejemplo n.º 6
0
        public static RoomTypeModel GetRoomTypeModel(int id)
        {
            RoomTypeModel rt   = null;
            SqlConnection conn = Connection.GetConnection();

            if (conn != null)
            {
                string     sql = "select * from RoomType where RoomTypeID = @id";
                SqlCommand cm  = new SqlCommand(sql, conn);
                cm.Parameters.AddWithValue("@id", id);
                var rs = cm.ExecuteReader();
                if (rs.HasRows)
                {
                    if (rs.Read())
                    {
                        rt             = new RoomTypeModel();
                        rt.RoomTypeID  = rs.GetInt32(0);
                        rt.RoomStyle   = RoomStyleDAO.GetRoomStyle(rs.GetInt32(1));
                        rt.RoomSize    = RoomSizeDAO.GetRoomSize(rs.GetInt32(2));
                        rt.Price       = rs.GetInt32(3);
                        rt.Description = rs.GetString(4);
                    }
                }
                conn.Close();
            }
            ;
            return(rt);
        }
Ejemplo n.º 7
0
        public async Task RoomService_AddRoomTypeAsync_Test()
        {
            try
            {
                using (var db = new DatabaseContext(dbContextOpt.Options))
                {
                    var userId     = Guid.Parse("AC087774-4D7C-47CA-A926-373D9A6C580A");
                    var propertyId = Guid.Parse("D95FF806-C50A-4A54-A476-02D350B2C6FA");

                    var roomTypeModel = new RoomTypeModel
                    {
                        Type       = "Double Occupancy",
                        Price      = 6000,
                        PropertyId = propertyId
                    };

                    var roomType = new RoomTypes
                    {
                        Id         = Guid.NewGuid(),
                        Type       = roomTypeModel.Type,
                        Price      = roomTypeModel.Price,
                        PropertyId = roomTypeModel.PropertyId
                    };

                    db.RoomTypes.Add(roomType);
                    await db.SaveChangesAsync();
                }
            }
            catch (Exception ex)
            {
                logService.Log("Add Room Type", ex.InnerException.Message, ex.Message, ex.StackTrace);
                Assert.Fail();
            }
        }
Ejemplo n.º 8
0
        public static List <RoomTypeModel> GetAllRoomTypeModel()
        {
            List <RoomTypeModel> list = new List <RoomTypeModel>();
            SqlConnection        conn = Connection.GetConnection();

            if (conn != null)
            {
                string     sql = "select * from RoomType";
                SqlCommand cm  = new SqlCommand(sql, conn);
                var        rs  = cm.ExecuteReader();
                if (rs.HasRows)
                {
                    while (rs.Read())
                    {
                        RoomTypeModel rt = new RoomTypeModel();
                        rt.RoomTypeID  = rs.GetInt32(0);
                        rt.RoomStyle   = RoomStyleDAO.GetRoomStyle(rs.GetInt32(1));
                        rt.RoomSize    = RoomSizeDAO.GetRoomSize(rs.GetInt32(2));
                        rt.Price       = rs.GetInt32(3);
                        rt.Description = rs.GetString(4);
                        list.Add(rt);
                    }
                }
                conn.Close();
            }
            ;
            return(list);
        }
Ejemplo n.º 9
0
 public IEnumerable <BookingViewModel> GetAllBookings()
 {
     using (HotelDBContext _hotelEntities = new HotelDBContext())
     {
         var data = _hotelEntities.Bookings.ToList();
         List <BookingViewModel> bookingList = new List <BookingViewModel>();
         for (var i = 0; i < data.Count; i++)
         {
             BookingViewModel bookingView = new BookingViewModel();
             bookingView.Id            = data[i].Id;
             bookingView.InvoiceNumber = data[i].InvoiceNumber;
             bookingView.HotelId       = Convert.ToInt32(data[i].HotelId);
             bookingView.RoomId        = Convert.ToInt32(data[i].RoomId);
             RoomTypeModel roomModel = GetAllRoomType().SingleOrDefault(x => x.Id == bookingView.RoomId);
             bookingView.FromDate    = roomModel.RoomName;
             bookingView.ToDate      = roomModel.RoomName;
             bookingView.BookingDate = roomModel.RoomName;
             bookingView.Adult       = data[i].Adult;
             bookingView.Children    = data[i].Children;
             bookingView.BuyingPrice = data[i].BuyingPrice;
             bookingList.Add(bookingView);
         }
         return(bookingList);
     }
 }
Ejemplo n.º 10
0
        /// <summary>
        /// Insert a new value in the list
        /// </summary>
        /// <param name=<em>"value"</em>>New value to be inserted</param>
        // POST: api/RoomType


        public IHttpActionResult Post(RoomTypeModel country)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("Not a valid model"));
            }

            using (var ctx = new HTMEntities3())
            {
                ctx.RoomTypes.Add(new RoomType()
                {
                    id           = country.id,
                    RoomName     = country.RoomName,
                    Description  = country.Description,
                    BedId        = country.BedId,
                    RoomStatusId = country.RoomStatusId,
                    Code         = country.Code,
                    Max_Child_No = country.Max_Child_No,
                    Max_Adult_No = country.Max_Adult_No,
                    InsertedOn   = country.InsertedOn,
                    InsertedBy   = country.InsertedBy,
                    IsActive     = country.IsActive,
                    IsDelete     = country.IsDelete
                });

                ctx.SaveChanges();
            }

            return(Ok());
        }
Ejemplo n.º 11
0
 public static bool flag(RoomTypeModel room)
 {
     if (room.RTID1 == -1)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 12
0
 public ActionResult SaveRoomType(RoomTypeModel model)
 {
     if (model != null)
     {
         _IRoomTypeMasterService.Save(model);
     }
     return(View());
 }
Ejemplo n.º 13
0
        //添加房间
        private void btnAddRoom_Click(object sender, EventArgs e)
        {
            RoomTypeModel room = new RoomTypeModel();

            room.RTID1 = -1;
            EditingRoomForm editing = new EditingRoomForm(room);

            editing.Show();
        }
Ejemplo n.º 14
0
        public void BookGuest(string firstName, string lastName, DateTime startDate, DateTime endDate, int roomTypeId)
        {
            string sql     = @"select 1 from Guests where FirstName = @firstName and LastName = @lastName";
            int    results = _db.LoadData <dynamic, dynamic>(sql, new { firstName, lastName }, connectionStringName).Count();

            if (results == 0)
            {
                sql = @"insert into Guests (FirstName, LastName)
		                    values (@firstName, @lastName);"        ;

                _db.SaveData(sql, new { firstName, lastName }, connectionStringName);
            }

            sql = @"select [Id], [FirstName], [LastName]
	                    from Guests
	                    where FirstName = @firstName and LastName = @lastName LIMIT 1;"    ;

            GuestModel guest = _db.LoadData <GuestModel, dynamic>(sql,
                                                                  new { firstName, lastName },
                                                                  connectionStringName).First();

            RoomTypeModel roomType = _db.LoadData <RoomTypeModel, dynamic>("select * from RoomTypes where Id = @Id",
                                                                           new { Id = roomTypeId },
                                                                           connectionStringName).First();

            TimeSpan timeStaying = endDate.Date.Subtract(startDate.Date);

            sql = @"select r.*
	                from Rooms r
	                inner join RoomTypes t on t.Id = r.RoomTypeId
	                where r.RoomTypeId = @roomTypeId
	                and r.Id not in (
	                select b.RoomId
	                from Bookings b
	                where (@startDate < b.StartDate and @endDate > b.EndDate)
		                or (b.StartDate <= @endDate and @endDate < b.EndDate)
		                or (b.StartDate <= @startDate and @startDate < b.EndDate)
	                );"    ;

            List <RoomModel> availableRooms = _db.LoadData <RoomModel, dynamic>(sql,
                                                                                new { startDate, endDate, roomTypeId },
                                                                                connectionStringName);

            sql = @"insert into Bookings(RoomId, GuestId, StartDate, EndDate, TotalCost)
	                values (@roomId, @guestId, @startDate, @endDate, @totalCost);"    ;

            _db.SaveData(sql,
                         new
            {
                roomId    = availableRooms.First().Id,
                guestId   = guest.Id,
                startDate = startDate,
                endDate   = endDate,
                totalCost = timeStaying.Days * roomType.Price
            },
                         connectionStringName);
        }
Ejemplo n.º 15
0
 public void Clear()
 {
     CheckIn = new CheckInModel();
     Guests.Clear();
     Services.Clear();
     RoomType = new RoomTypeModel();
     GuestDocuments.Clear();
     roominess = roomNumber = -1;
     id        = 0;
 }
Ejemplo n.º 16
0
 public void CreateRoomType(RoomTypeModel obj, ref string roomtype, ref int retcode, ref string retmesg)
 {
     try
     {
         data.CreateRoomType(obj, ref roomtype, ref retcode, ref retmesg);
     }
     catch (Exception)
     {
     }
 }
Ejemplo n.º 17
0
        //修改房间
        private void btnUpdateRomm_Click(object sender, EventArgs e)
        {
            int             index    = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value);
            string          name     = dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[1].Value.ToString();
            int             minMoney = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[2].Value);
            int             flag     = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[3].Value);
            int             count    = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[4].Value);
            RoomTypeModel   room     = new RoomTypeModel(index, name, minMoney, flag, count);
            EditingRoomForm editing  = new EditingRoomForm(room);

            editing.Show();
        }
        public void Save(RoomTypeModel model)
        {
            RoomTypeMaster _objData = new RoomTypeMaster();

            _objData.RoomTypeName = model.RoomTypeName;
            _objData.RoomTypeCode = model.RoomTypeCode;
            _objData.ActiveStatus = model.ActiveStatus;
            _objData.UniqueID     = Guid.NewGuid().ToString();

            _Repository.Add(_objData);
            _Repository.Save();
        }
Ejemplo n.º 19
0
        private void OnSelectedRoomTypeItem(object sender, ItemTappedEventArgs e)
        {
            RoomTypeModel md  = (RoomTypeModel)lv_room_type.SelectedItem;
            int           cnt = Vm.RoomTypeList.IndexOf(md);

            if (cnt >= 0)
            {
                Vm.RoomTypeSelection(cnt);
            }

            ((ListView)sender).SelectedItem = null;
        }
Ejemplo n.º 20
0
        public JsonResult CreateRoomType(RoomTypeModel objRoomType)
        {
            objRoomType.Code      = new Locdau().LocDauChuoi(objRoomType.Name).ToUpper();
            objRoomType.DouldBed  = objRoomType.DouldBed < 0 ? 0: objRoomType.DouldBed;
            objRoomType.SingBed   = objRoomType.SingBed < 0 ? 0 : objRoomType.SingBed;
            objRoomType.UserLimit = objRoomType.UserLimit < 0 ? 0 : objRoomType.UserLimit;
            string mess     = "";
            string roomtype = "";
            int    retcode  = 0;

            new CRoomType().CreateRoomType(objRoomType, ref roomtype, ref retcode, ref mess);
            return(Json(new { notifi = mess }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 21
0
        public async Task <int> AddRoomType([FromBody] RoomTypeModel roomTypeModel)
        {
            var roomType = new RoomType()
            {
                Name  = roomTypeModel.Name,
                Price = roomTypeModel.Price,
            };
            await _hotelContext.RoomTypes.AddAsync(roomType);

            await _hotelContext.SaveChangesAsync();

            return(roomType.RoomTypeId);
        }
Ejemplo n.º 22
0
        //删除房间
        private void btnDeleteRoom_Click(object sender, EventArgs e)
        {
            int           index = Convert.ToInt32(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells[0].Value);
            RoomTypeModel room  = new RoomTypeModel();

            room.RTID1 = index;
            int result = RommBLL.getDelete(room);

            if (result > 0)
            {
                MessageBox.Show("OK");
            }
            else
            {
                MessageBox.Show("NO");
            }
        }
Ejemplo n.º 23
0
        public IEnumerable <RoomTypeModel> GetAllRoomType()
        {
            using (HotelDBContext _hotelEntities = new HotelDBContext())
            {
                var data = _hotelEntities.RoomTypes.ToList();
                List <RoomTypeModel> roomList = new List <RoomTypeModel>();

                for (var i = 0; i < data.Count; i++)
                {
                    RoomTypeModel room = new RoomTypeModel();
                    room.Id       = data[i].Id;
                    room.RoomName = data[i].RoomName;
                    roomList.Add(room);
                }
                return(roomList);
            }
        }
        public async Task RoomApi_AddRoomTypeAsync_IntegrationTest()
        {
            var propertyId = Guid.Parse("BCEDAB95-5E70-4A0B-83DC-0053D28A7D8F");
            var token      = await GenerateTokenAsync();

            client.DefaultRequestHeaders.Add("Authorization", $"Bearer {token.AccessToken}");

            var roomTypeModel = new RoomTypeModel
            {
                Type       = "4 person dorm aircon room",
                Price      = 3800,
                PropertyId = propertyId
            };

            var payload = new StringContent(
                JsonConvert.SerializeObject(roomTypeModel),
                Encoding.UTF8,
                "application/json"
                );

            try
            {
                var request = await client.PostAsync("api/v1/Room/type/add", payload);

                var response = await request.Content.ReadAsStringAsync();

                if (request.IsSuccessStatusCode)
                {
                    var content = JsonConvert.DeserializeObject <ResponseModel>(response);

                    Assert.IsTrue(content.Status);
                }
                else
                {
                    var resp = JsonConvert.DeserializeObject <ResponseModel>(response);

                    Assert.Fail(resp.Message);
                }
            }
            catch (Exception ex)
            {
                logService.Log("API Endpoint: Add Room Type", ex.InnerException.Message, ex.Message, ex.StackTrace);
                Assert.Fail(ex.Message);
            }
        }
Ejemplo n.º 25
0
 public RoomTypeModel GetRoomById(int roomID)
 {
     using (HotelDBContext _hotelEntities = new HotelDBContext())
     {
         var data = _hotelEntities.RoomTypes.ToList();
         List <RoomTypeModel> roomList = new List <RoomTypeModel>();
         for (var i = 0; i < data.Count; i++)
         {
             RoomTypeModel model = new RoomTypeModel();
             model.Id        = data[i].Id;
             model.RoomName  = data[i].RoomName;
             model.Amenities = data[i].Amenities;
             roomList.Add(model);
         }
         RoomTypeModel getRoomData = roomList.SingleOrDefault(x => x.Id == roomID);
         return(getRoomData);
     }
 }
        public List <RoomTypeModel> OdaTurlerComboBoxDoldur()
        {
            List <RoomTypeModel> roomTypeModels = new List <RoomTypeModel>();

            using (PGDatabase dbd = new PGDatabase())
            {
                string           command = "select * from odatype ";
                NpgsqlDataReader reader  = dbd.Reader(command);
                while (reader.Read())
                {
                    RoomTypeModel roomType = new RoomTypeModel();
                    roomType.id        = Convert.ToInt32(reader["id"]);
                    roomType.odaTurAdi = (reader["odaturadi"]).ToString();
                    roomTypeModels.Add(roomType);
                }
                reader.Close();
                dbd.connClose();
            }
            return(roomTypeModels);
        }
        public async Task <IActionResult> PostRoomTypeAsync([FromBody] RoomTypeModel obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            var response = await _roomService.AddRoomTypesAsync(obj);

            _responseModel.Status  = response.Status;
            _responseModel.Message = response.Message;

            if (_responseModel.Status)
            {
                return(Ok(_responseModel));
            }
            else
            {
                return(BadRequest(_responseModel));
            }
        }
Ejemplo n.º 28
0
        public IActionResult RoomTypeSettings(RoomTypeModel model)
        {
            var list = new List <RoomTypeSettings>();

            for (var i = 0; i < model.RoomTypeName.Count; i++)
            {
                var rateLevelsList = new List <RateLevel>();
                for (var j = 0; j < model.RoomRateLevelsCount[i]; j++)
                {
                    rateLevelsList.Add(new RateLevel());
                }
                list.Add(new RoomTypeSettings
                {
                    RoomTypeName = model.RoomTypeName[i],
                    RateLevels   = rateLevelsList
                });
            }

            return(View(new RoomTypeSettingsModel {
                CorrectList = list
            }));
        }
Ejemplo n.º 29
0
        public void LoadData(int checkInId)
        {
            CheckIn        = dbCrud.GetCheckIn(checkInId);
            Guests         = dbInfo.FindGuests(checkInId);
            GuestDocuments = new List <GuestDocuments>();
            foreach (GuestModel guest in Guests)
            {
                GuestDocuments.Add(new GuestDocuments(guest.Document.TrimEnd(' ')));
            }
            RoomModel room = dbCrud.GetRoom(CheckIn.RoomId);

            Roominess  = room.NumberOfPlaces;
            RoomNumber = room.RoomNumber;
            Services   = new List <ServiceData>();
            List <CheckInServiceModel> checkInServices = dbInfo.FindServices(checkInId);

            foreach (CheckInServiceModel checkInServiceModel in checkInServices)
            {
                Services.Add(new ServiceData(dbCrud.GetService(checkInServiceModel.ServiceId), checkInServiceModel.Number));
            }
            RoomType = dbCrud.GetRoomType(room.TypeId);
        }
Ejemplo n.º 30
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string name     = txtName.Text.Trim();
            int    minMoney = Convert.ToInt32(txtMin.Text.Trim());
            int    flag     = cb.Checked ? 1 : 0;
            int    count    = Convert.ToInt32(txtCount.Text.Trim());

            if (room.RTID1 == -1)
            {
                //添加
                RoomTypeModel room2  = new RoomTypeModel(name, minMoney, flag, count);
                int           result = RommBLL.getAdd(room2);
                if (result > 0)
                {
                    MessageBox.Show("OK");
                }
                else
                {
                    MessageBox.Show("NO");
                }
            }
            else
            {
                //修改
                RoomTypeModel room2  = new RoomTypeModel(room.RTID1, name, minMoney, flag, count);
                int           result = RommBLL.getUpdate(room2);
                if (result > 0)
                {
                    MessageBox.Show("OK");
                }
                else
                {
                    MessageBox.Show("NO");
                }
            }
        }