Esempio n. 1
0
        public async Task <Roomtype> AddRoomTypeAsync(Roomtype roomType)
        {
            _dbContext.Set <Roomtype>().Add(roomType);
            await _dbContext.SaveChangesAsync();

            return(roomType);
        }
Esempio n. 2
0
        public async Task <Roomtype> UpdateRoomTypeAsync(Roomtype roomType)
        {
            _dbContext.Entry(roomType).State = EntityState.Modified;
            await _dbContext.SaveChangesAsync();

            return(roomType);
        }
Esempio n. 3
0
        public void CreateRoomTest()
        {
            List <Room> roomTest = new List <Room>();
            Roomtype    roomType = new Roomtype();
            Room        room     = new Room();

            room.Roomnum     = 1;
            room.Roomtypesid = 2;
            room.Id          = 1;
            room.Cleaned     = true;
            room.LastCleaned = DateTime.Now;

            roomType.Name    = "King-Kong Size";
            roomType.Qtybeds = 2;
            roomType.Cost    = 7777;
            roomType.Rooms.Add(room);
            roomType.Id = 1;

            room.Roomtypes = roomType;

            roomTest.Add(room);

            Assert.IsNotNull(roomTest);
            Assert.IsNotNull(roomType);
        }
Esempio n. 4
0
        public IHttpActionResult PutRoomtype(int id, Roomtype roomtype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != roomtype.Type_Id)
            {
                return(BadRequest());
            }

            db.Entry(roomtype).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RoomtypeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 5
0
        public IHttpActionResult GetRoomtype(int id)
        {
            Roomtype roomtype = db.Roomtypes.Find(id);

            if (roomtype == null)
            {
                return(NotFound());
            }

            return(Ok(roomtype));
        }
Esempio n. 6
0
        public IHttpActionResult PostRoomtype(Roomtype roomtype)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Roomtypes.Add(roomtype);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = roomtype.Type_Id }, roomtype));
        }
 public ActionResult AddRoomType(Roomtype roomtype)
 {
     try
     {
         _hotelReservationService.SaveRoomType(roomtype);
         ViewBag.SuccessMessage = "Room Type Added Successfully";
     }
     catch (Exception)
     {
         ViewBag.ErrorMessage = "Failed to Save!";
     }
     return(View());
 }
Esempio n. 8
0
        public IHttpActionResult DeleteRoomtype(int id)
        {
            Roomtype roomtype = db.Roomtypes.Find(id);

            if (roomtype == null)
            {
                return(NotFound());
            }

            db.Roomtypes.Remove(roomtype);
            db.SaveChanges();

            return(Ok(roomtype));
        }
 public ActionResult Edit(Roomtype roomtype)
 {
     try
     {
         Roomtype roomtypeProxy = _hotelReservationService.GetRoomTypeById(roomtype.Id);
         roomtypeProxy.Name         = roomtype.Name;
         roomtypeProxy.Description  = roomtype.Description;
         roomtypeProxy.Ratepernight = roomtype.Ratepernight;
         _hotelReservationService.UpdateRoomType(roomtypeProxy);
         ViewBag.SuccessMessage = "Updated Successfully";
     }
     catch (Exception)
     {
         ViewBag.ErrorMessage = "Upgradation Failed";
     }
     return(View(roomtype));
 }
 public ActionResult Delete(Roomtype roomtype)
 {
     try
     {
         Roomtype roomtypeProxy = _hotelReservationService.GetRoomTypeById(roomtype.Id);
         roomtypeProxy.Status = Roomtype.EntityStatus.Delete;
         foreach (var room in roomtypeProxy.Rooms)
         {
             room.Status = Room.EntityStatus.Delete;
         }
         _hotelReservationService.UpdateRoomType(roomtypeProxy);
         ViewBag.SuccessMessage = "Deleted Successfully";
     }
     catch (Exception)
     {
         ViewBag.ErrorMessage = "Upgradation Failed";
     }
     return(View(roomtype));
 }
Esempio n. 11
0
        /// <summary>
        /// override string method that will give us the information that we want to add to the listbox in the end
        /// </summary>
        public override string ToString()
        {
            string nightstring;

            if (Checkoutdate == Checkindate)
            {
                nightstring = "0"; if (CurrentNumOfCostumers() != 0)
                {
                    nightstring = "1";
                }
            }
            else
            {
                nightstring = ((Checkoutdate - Checkindate).Days).ToString();
            }
            string str = Roomtype.ToString() + "     " + CurrentNumOfCostumers().ToString() + " / " + capacity.ToString() + " Total Nights:" + nightstring;

            return(str);
        }
Esempio n. 12
0
        public void UpdateRoomType(Roomtype roomtypeProxy)
        {
            ITransaction transaction = null;

            try
            {
                using (transaction = _session.BeginTransaction())
                {
                    _roomTypeDao.Update(roomtypeProxy);
                    transaction.Commit();
                }
            }
            catch (Exception)
            {
                if (transaction != null)
                {
                    transaction.Rollback();
                }
                throw;
            }
        }
        public ActionResult AddRoom(RoomVm roomVm)
        {
            try
            {
                Roomtype roomtype = _hotelReservationService.GetRoomTypeById(roomVm.RoomTypeId);
                Room     room     = new Room();
                room.Roomno      = roomVm.RoomNo;
                room.Noofadult   = roomVm.NoOfAdult;
                room.Roomtype    = roomtype;
                room.Description = roomVm.Description;
                room.Maxchild    = roomVm.MaxChild;

                _hotelReservationService.SaveRoom(room);
                ViewBag.roomTypes      = new SelectList(_hotelReservationService.LoadAllRoomType(), "Id", "Name");
                ViewBag.SuccessMessage = "Room Saved Successfully";
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = "Failed to Save!";
            }
            return(View());
        }
        public ActionResult EditRoom(RoomVm roomVm)
        {
            try
            {
                Roomtype roomtype = _hotelReservationService.GetRoomTypeById(roomVm.RoomTypeId);
                Room     room     = _hotelReservationService.GetRoomById(roomVm.Id);
                room.Roomno      = roomVm.RoomNo;
                room.Noofadult   = roomVm.NoOfAdult;
                room.Roomtype    = roomtype;
                room.Description = roomVm.Description;
                room.Maxchild    = roomVm.MaxChild;

                _hotelReservationService.UpdateRoom(room);
                ViewBag.roomTypes      = new SelectList(_hotelReservationService.LoadAllRoomType(), "Id", "Name");
                ViewBag.SuccessMessage = "Room Updated Successfully";
                return(View(new RoomVm()));
            }
            catch (Exception)
            {
                ViewBag.ErrorMessage = "Upgradation Failed";
                throw;
            }
        }
Esempio n. 15
0
 public void SaveRoomType(Roomtype roomtype)
 {
     _roomTypeDao.Save(roomtype);
 }
Esempio n. 16
0
 public async Task DeleteRoomTypeAsync(Roomtype roomType)
 {
     _dbContext.Set <Roomtype>().Remove(roomType);
     await _dbContext.SaveChangesAsync();
 }
        public ActionResult Edit(long id)
        {
            Roomtype roomtype = _hotelReservationService.GetRoomTypeById(id);

            return(View(roomtype));
        }