public async Task <IActionResult> AddSongToRoom(RoomVM roomVM)
        {
            var spotify = new SpotifyService(roomVM.CurrentRoom.SpotifyAuthCode);
            var song    = await spotify.GetSong(roomVM.SongToAdd);

            var  token    = Request.Headers["Authorization"].ToString().Replace("Bearer ", "");
            var  username = _tokenService.GetNameFromToken(token);
            Room room     = null;

            try
            {
                room = await _roomDataStore.AddSongToRoomAsync(username, roomVM.CurrentRoom.Id.ToString(), song);

                var playlist = await _spotifyPlaylistsStore.GetItemByRoomId(room.Id.ToString());

                await spotify.AddSongToPlaylist(playlist, song);

                await _roomDataStore.RemovePreviouslyPlayedSongsAsync(room.Id);
            }
            catch { }


            if (room != null)
            {
                await _roomHub.Clients.All.SendAsync("Update", room.Id.ToString());

                return(PartialView("Components/_roomSongListItem", room.RoomSongs));
            }

            return(PartialView("Components/_roomSongListItem", room.RoomSongs));
        }
예제 #2
0
        // ----------------------------- this view is only for static run (TEMP VIEW)
        public ActionResult HotelCheckout()
        {
            List <RoomVM> rooms = new List <RoomVM>();
            RoomVM        room1 = new RoomVM()
            {
                roomPrice       = 250.22,
                roomDescription = "bla bla bla blabla bla bla bla",
                roomComposition = "Single"
            };
            RoomVM room2 = new RoomVM()
            {
                roomPrice       = 581.85,
                roomDescription = "bla bla bla bla",
                roomComposition = "Adult + 2 Children"
            };

            rooms.Add(room1);
            rooms.Add(room2);
            rooms.Add(new RoomVM()); // always pass 3 rooms

            HotelCheckoutVM hotelCheckoutVM = new HotelCheckoutVM()
            {
                hotelName     = "Globales Acis Y Galatea",
                numberOfRooms = 2,
                room          = rooms,
                startDate     = "15.06.2018",
                endDate       = "18.06.2018",
                hotelAddress  = "Galatea 6 Madrid"
            };

            return(View(hotelCheckoutVM));
        }
예제 #3
0
        public void editRoom()
        {
            RoomVM roomVM = _iRoomBLL.getAll(1, 2, "hello")[0];

            roomVM.RoomName = "Room1";
            //edit status time
            roomVM.ListStatusTime[0].StatimTodate = Convert.ToDateTime("01/10/2021");

            //add Status time
            StatusVM statusVM = new StatusVM();

            statusVM.IdStatus = 1;
            StatusTimeVM statusTimeVM = new StatusTimeVM();

            //statusTimeVM.IdStatim = 4; //gia su minh sua lai thong tin tk status_time da co trong db
            statusTimeVM.StatimFromdate = DateTime.Now;
            statusTimeVM.StatimTodate   = Convert.ToDateTime("12/12/2021");
            statusTimeVM.statusVM       = statusVM;
            roomVM.ListStatusTime.Add(statusTimeVM);

            //del sattus time
            // List<int>listdel = new List<int>();
            // listdel.Add(3);
            _iRoomBLL.editRoom(roomVM, null);
        }
        public void editRoom1(RoomVM roomVM, List <int> listdel)
        {
            Room room = new Room();

            _iMapper.Map(roomVM, room);
            room.RoomIdroomtype = roomVM.MapRoomtype.First().Key;
            foreach (StatusTimeVM statusTimeVM in roomVM.ListStatusTime)
            {
                StatusTime statusTime = new StatusTime();
                _iMapper.Map(statusTimeVM, statusTime);
                // Status status = new Status();
                // _iMapper.Map(statusTimeVM.statusVM,status);
                // statusTime.StatimIdstatusNavigation = status;
                statusTime.StatimIdstatus = statusTimeVM.statusVM.IdStatus;
                statusTime.StatimIdroom   = room.IdRoom;
                room.StatusTimes.Add(statusTime);
            }
            try{
                _iRoomDAL.update(room);
                if (listdel.Count != 0)
                {
                    _iStatusTimeDAL.delete(listdel);
                }
            }catch (Exception e) {
                Console.WriteLine(e.Message);
            }
        }
예제 #5
0
        public async Task <ActionResult> EditRoom(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Room room = await db.Rooms.FindAsync(id);

            if (room == null)
            {
                return(HttpNotFound());
            }

            var roomVM = new RoomVM
            {
                Id          = room.Id,
                Number      = room.Number,
                Description = room.Description,
                RoomType    = room.RoomType,
                RoomTypeId  = room.RoomTypeId,
                Rate        = room.Rate,
                Floor       = room.Floor
            };

            PopulateRoomsList();
            PopulateRoomTypesDropDownList(roomVM.RoomTypeId);

            return(View(roomVM));
        }
예제 #6
0
        private List <RoomVM> HotelDetailsHelper3(string link, int index)
        { // this function help to get the room description from the JSON
            var json = "";

            using (WebClient wc = new WebClient())
            {
                json = wc.DownloadString(link);
            }

            dynamic results = JsonConvert.DeserializeObject(json);

            List <RoomVM> lst = new List <RoomVM>();

            for (int i = 0; i < results.results[index].rooms.Count; ++i)
            {
                List <string> roomTypeTEMP = new List <string>();
                string        str          = "Room type: " + results.results[index].rooms[i].room_type_info.room_type;
                roomTypeTEMP.Add(str);
                str = "Bed type: " + results.results[index].rooms[i].room_type_info.bed_type;
                roomTypeTEMP.Add(str);
                str = "Number of beds: " + results.results[index].rooms[i].room_type_info.number_of_beds;
                roomTypeTEMP.Add(str);

                RoomVM temp = new RoomVM()
                {
                    roomPrice       = results.results[index].rooms[i].total_amount.amount,
                    roomDescription = results.results[index].rooms[i].descriptions[1],
                    roomType        = roomTypeTEMP
                };

                lst.Add(temp);
            }

            return(lst);
        }
        public async Task <IActionResult> Edit(int?id, RoomVM roomVM)
        {
            IEnumerable <Category> categories = await _dbContext.Categories.ToListAsync();

            if (id == null)
            {
                roomVM.Categories = categories;
            }

            if (!ModelState.IsValid)
            {
                roomVM.Categories = categories;
            }

            Room room = await _dbContext.Rooms.FindAsync(id);

            room.RoomNumber  = roomVM.Room.RoomNumber;
            room.Price       = roomVM.Room.Price;
            room.IsReserved  = roomVM.Room.IsReserved;
            room.CategoryId  = roomVM.SelectedCategory;
            room.Description = roomVM.Room.Description;
            room.Breakfast   = roomVM.Room.Breakfast;
            room.WiFi        = roomVM.Room.WiFi;
            room.BedCount    = roomVM.Room.BedCount;

            await _dbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #8
0
 // GET: Room/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id != null)
     {
         Room rm = db.Room.FirstOrDefault(t => t.id == id);
         if (rm != null)
         {
             RoomVM model = new RoomVM()
             {
                 Room   = rm,
                 Rooms  = db.Room.ToList(),
                 Header = "Edit Room",
                 Action = "Edit"
             };
             return(View("Index", model));
         }
         else
         {
             return(HttpNotFound());
         }
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
        public async Task <List <RoomVM> > GetAllRommEmp()
        {
            List <RoomVM> list = new List <RoomVM>();

            var getUserRole = await _context.Rooms.Include("Booking").Where(x => x.isDelete == false && x.isBook == true).ToListAsync();

            if (getUserRole.Count == 0)
            {
                return(null);
            }
            foreach (var item in getUserRole)
            {
                var user = new RoomVM()
                {
                    Id          = item.Id,
                    RoomName    = item.Name,
                    BookingId   = item.BookingId,
                    BookingName = item.Booking.Name,
                    isDelete    = item.isDelete,
                    DeleteDate  = item.DeleteDate,
                    CreateDate  = item.CreateDate,
                    UpdateDate  = item.UpdateDate,
                    isBook      = item.isBook,
                    Time        = item.Booking.Time,
                    EndDate     = item.Booking.EndDate
                                  //TeamLeader = item.Booking.Employee.FullName
                };
                list.Add(user);
            }
            return(list);
        }
        public async Task <IActionResult> Create(RoomVM roomVM)
        {
            if (!ModelState.IsValid)
            {
                roomVM.Categories = await _dbContext.Categories.ToListAsync();

                return(View(roomVM.Categories));
            }

            Room room = new Room
            {
                RoomNumber  = roomVM.Room.RoomNumber,
                CategoryId  = roomVM.SelectedCategory,
                BedCount    = roomVM.Room.BedCount,
                Breakfast   = roomVM.Room.Breakfast,
                Description = roomVM.Room.Description,
                IsReserved  = roomVM.Room.IsReserved,
                Price       = roomVM.Room.Price,
                WiFi        = roomVM.Room.WiFi
            };

            await _dbContext.AddAsync(room);

            await _dbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
예제 #11
0
        private List <RoomVM> HotelDetailsHelper2(dynamic results)
        { // this function help to get the room description from the JSON
            List <RoomVM> lst = new List <RoomVM>();

            for (int i = 0; i < results.rooms.Count; ++i)
            {
                List <string> roomTypeTEMP = new List <string>();
                string        str          = "Room type: " + results.rooms[i].room_type_info.room_type;
                roomTypeTEMP.Add(str);
                str = "Bed type: " + results.rooms[i].room_type_info.bed_type;
                roomTypeTEMP.Add(str);
                str = "Number of beds: " + results.rooms[i].room_type_info.number_of_beds;
                roomTypeTEMP.Add(str);

                RoomVM temp = new RoomVM()
                {
                    roomPrice       = results.rooms[i].total_amount.amount,
                    roomDescription = results.rooms[i].descriptions[1],
                    roomType        = roomTypeTEMP
                };

                lst.Add(temp);
            }

            return(lst);
        }
예제 #12
0
        public static ViewHotelOrderVM returnHotel(Order order)
        {
            ViewHotelOrderVM ovm = new ViewHotelOrderVM();

            DataLayer dl = new DataLayer();

            ovm.invoice = order.InvoiceNumber;

            ovm.creditCardNumber = order.CreditCard;

            HotelOrder hotelorder = (from x in dl.hotelOrders
                                     where x.InvoiceID == ovm.invoice
                                     select x).ToList <HotelOrder>().FirstOrDefault();

            ovm.hotelName = hotelorder.HotelName;

            ovm.startDate = hotelorder.StartDate;

            ovm.endDate = hotelorder.EndDate;

            ovm.orderDate = order.OrderDate;

            ovm.status = order.Status;

            ovm.email = order.CustomerEmail;

            Customer cust = (from x in dl.customers
                             where x.Email == ovm.email
                             select x).ToList <Customer>().FirstOrDefault();

            ovm.customerName = cust.FullName;

            ovm.customerId = cust.ID;

            List <HotelOrderDetails> hod = (from x in dl.hotelOrderDetails
                                            where x.Invoice == ovm.invoice
                                            select x).ToList <HotelOrderDetails>();

            ovm.totalPrice = order.TotalPayment;

            //ovm.rooms = null;
            ovm.numberOfRooms = hod.Count;

            List <RoomVM> rooms = new List <RoomVM>();

            for (int i = 0; i < hod.Count; ++i)
            {
                RoomVM r = new RoomVM()
                {
                    roomComposition = hod[i].RoomComposition,
                    roomPrice       = hod[i].PaymentForRoom,
                    roomDescription = hod[i].RoomType
                };
                rooms.Add(r);
            }


            ovm.rooms = rooms;
            return(ovm);
        }
예제 #13
0
        // GET: Room
        public ActionResult Index()
        {
            //1. Create a RoomRepository for loading the data
            RoomRepository roomRepository = new RoomRepository();
            //2. Get a list of rooms
            List <Room> rooms = roomRepository.LoadAllRooms();
            //3. Translate each room into a RoomVM
            List <RoomVM> roomVMs = new List <RoomVM>();

            foreach (Room room in rooms)
            {
                //create the actual translation
                RoomVM roomvm = new RoomVM();
                roomvm.Id          = room.Id;
                roomvm.Name        = room.Name;
                roomvm.Description = room.Description;
                roomvm.RoomNumber  = room.RoomNumber;
                roomvm.IsOccupied  = false;
                //add it to the list
                roomVMs.Add(roomvm);
            }
            //4. Send it back to the view
            RoomVM model = new RoomVM();

            model.Rooms = roomVMs;
            return(View(model));
        }
예제 #14
0
        public ActionResult ShowAddRoom(Guid?roomTypeId)
        {
            try
            {
                var roomTypeList = new SelectList(roomTypeRepository.GetRoomType(string.Empty), "Id", "RoomTypeCode");
                var floorList    = new SelectList(floorRepository.GetFloors(), "Id", "Name");

                ViewBag.RoomTypeList = roomTypeList;
                ViewBag.FloorList    = floorList;

                RoomVM model = new RoomVM();
                model.IsActive = true;

                if (roomTypeId.HasValue)
                {
                    model.RoomTypeId = roomTypeId.Value;
                }

                return(PartialView("_AddRoom", model));
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "ShowAddRoom");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }
        public ActionResult AddRoom(RoomVM addRoomVM)
        {
            if (ModelState.IsValid)
            {
                var amenityIds = new List <int>();
                if (addRoomVM.SelectedAmenityIds != null)
                {
                    foreach (var amenityId in addRoomVM.SelectedAmenityIds)
                    {
                        amenityIds.Add(int.Parse(amenityId));
                    }
                }


                this.roomService.AddRoom(addRoomVM.Cost, addRoomVM.MaxNumberOfGuests, addRoomVM.RoomSize, amenityIds);
                TempData["message"] = "Room added";
                return(RedirectToAction("Rooms"));
            }

            addRoomVM.AllAmenities = roomService.GetAllAmenities().Select(a => new AmenityVM
            {
                AmenityId   = a.AmenityId,
                AmenityName = a.AmenityName
            }).ToList();

            return(View(addRoomVM));
        }
예제 #16
0
        public async Task <ActionResult> Create(RoomVM roomVM)
        {
            PopulateRoomsList();
            PopulateRoomTypesDropDownList(roomVM.RoomTypeId);

            if (RoomNumberExists(roomVM.Number))
            {
                ModelState.AddModelError("", "Room number you entered already exists. Enter different number.");
            }

            if (ModelState.IsValid)
            {
                var room = new Room
                {
                    Number      = roomVM.Number,
                    Description = roomVM.Description,
                    RoomTypeId  = roomVM.RoomTypeId,
                    Floor       = roomVM.Floor,
                    Rate        = roomVM.Rate
                };

                db.Rooms.Add(room);
                await db.SaveChangesAsync();

                TempData["Message"] = "Room added successfully.";

                return(RedirectToAction("Create"));
            }

            return(View(roomVM));
        }
        public ActionResult DeleteConfirmed(int id, RoomVM roomVM)
        {
            var query   = db.Rooms.Single(t => t.RoomID == id);
            var trainee = Mapper.Map <Room, RoomVM>(query);

            db.Rooms.Remove(query);  //
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #18
0
 private RoomVM[] VmFromRooms(Room[] rooms)
 {
     RoomVM[] roomVM = new RoomVM[rooms.Length];
     for (int i = 0; i < rooms.Length; i++)
     {
         roomVM[i] = RoomVM.From(rooms[i]);
     }
     return(roomVM);
 }
        public async Task <IActionResult> Index(DateTime?startDate, DateTime?endDate, int?count)
        {
            if (startDate == null || endDate == null || count == null)
            {
                return(RedirectToAction("Error", "Home"));
            }

            RoomVM roomVM = new RoomVM();

            string selectedDates = "";

            for (DateTime day = Convert.ToDateTime(startDate); day <= endDate; day = day.AddDays(1))
            {
                selectedDates += "<" + day.ToShortDateString() + ">";
            }

            string orderId             = "";
            IEnumerable <Order> orders = await _dbContext.Orders.ToListAsync();

            foreach (var order in orders)
            {
                for (DateTime orderDay = order.StartDate.Date; orderDay <= order.EndDate.Date; orderDay = orderDay.AddDays(1))
                {
                    if (selectedDates.Contains("<" + orderDay.ToShortDateString() + ">"))
                    {
                        orderId += "/" + order.ID + "/";
                    }
                }
            }

            IEnumerable <Room> rooms = from room in _dbContext.Rooms
                                       join category in _dbContext.Categories
                                       on room.CategoryId equals category.Id
                                       join order in _dbContext.Orders
                                       on room.ID equals order.RoomId
                                       join roomImage in _dbContext.RoomImages
                                       on room.ID equals roomImage.RoomId
                                       where (orderId.Contains("/" + order.ID.ToString() + "/"))
                                       select new Room
            {
                ID = room.ID
            };

            string roomId = "";

            foreach (var room in rooms)
            {
                roomId += "/" + room.ID + "/";
            }

            roomVM.Rooms = await _dbContext.Rooms
                           .Include(x => x.RoomImages)
                           .Include(x => x.Category)
                           .Where(x => !roomId.Contains("/" + x.ID.ToString() + "/")).ToListAsync();

            return(View(roomVM));
        }
        public async Task <IActionResult> Create()
        {
            RoomVM roomVM = new RoomVM
            {
                Categories = await _dbContext.Categories.ToListAsync()
            };

            return(View(roomVM));
        }
        /// <summary>
        /// 编辑
        /// </summary>
        /// <returns></returns>
        public ActionResult Edit(RoomVM vm)
        {
            vm.Room = _RoomService.GetById(vm.Id) ?? new Room();
            //获取餐厅列表
            int tcount = 0;

            vm.BusinessList = _businessService.GetListByType((int)BusinessTypeEnum.酒店, 1, 1000, out tcount);

            return(View(vm));
        }
예제 #22
0
        // GET: Rooms/Create
        public IActionResult Create()
        {
            object obj = new RoomVM
            {
                Facilities = _context.Facility.ToList(),
                RoomTypes  = _context.RoomType.ToList(),
            };

            return(View(obj));
        }
예제 #23
0
        public IHttpActionResult CreateRoom(RoomVM res)
        {
            var mng = new RoomManager();

            var room = RoomMapper.MapRoomVM(res);

            mng.AddNewRoom(room);

            return(Ok(res));
        }
예제 #24
0
        public ActionResult Index(RoomVM roomVM)
        {
            string imageUniqueName = String.Empty;
            string actualImageName = String.Empty;
            string message         = String.Empty;

            if (roomVM.roomId == 0)
            {
                imageUniqueName = Guid.NewGuid().ToString();
                actualImageName = imageUniqueName + Path.GetExtension(roomVM.Image.FileName);
                roomVM.Image.SaveAs(Server.MapPath("~/RoomImages/" + actualImageName));

                Room room = new Room()
                {
                    roomNumber      = roomVM.roomNumber,
                    roomPrice       = roomVM.roomPrice,
                    roomDescription = roomVM.roomDescription,
                    roomCapacity    = roomVM.roomCapacity,
                    roomTypeId      = roomVM.roomTypeId,
                    isActive        = true,
                    bookingStatusId = roomVM.bookingStatusId,
                    roomImage       = actualImageName
                };

                db.Room.Add(room);
                message = "Room saved successfully.";
            }
            else
            {
                Room roomToEdit = db.Room.Single(m => m.roomId == roomVM.roomId);

                if (roomVM.Image != null)
                {
                    imageUniqueName = Guid.NewGuid().ToString();
                    actualImageName = imageUniqueName + Path.GetExtension(roomVM.Image.FileName);
                    roomVM.Image.SaveAs(Server.MapPath("~/RoomImages/" + actualImageName));
                    roomToEdit.roomImage = actualImageName;
                }

                roomToEdit.roomNumber      = roomVM.roomNumber;
                roomToEdit.roomPrice       = roomVM.roomPrice;
                roomToEdit.roomDescription = roomVM.roomDescription;
                roomToEdit.roomCapacity    = roomVM.roomCapacity;
                roomToEdit.roomTypeId      = roomVM.roomTypeId;
                roomToEdit.isActive        = true;
                roomToEdit.bookingStatusId = roomVM.bookingStatusId;

                message = "Room updated successfully.";
            }

            db.SaveChanges();

            return(Json(new { message = message, success = true }, JsonRequestBehavior.AllowGet));
        }
예제 #25
0
        // GET: Room
        public ActionResult Index()
        {
            RoomVM model = new RoomVM()
            {
                Room   = new Room(),
                Rooms  = db.Room.ToList(),
                Header = "Add Room",
                Action = "Create"
            };

            return(View(model));
        }
예제 #26
0
 /// <summary>
 /// Removes a room from the job
 /// </summary>
 /// <param name="roomToDelete">The room that needs to be deleted</param>
 public void Remove(RoomVM roomToDelete)
 {
     if (MessageBox.Show("Deleting this room will delete all items contained in it. \nAre you sure you want to continue?",
                         "Warning",
                         MessageBoxButton.YesNo) == MessageBoxResult.Yes)
     {
         if (Rooms.Contains(roomToDelete))
         {
             Rooms.Remove(roomToDelete);
         }
     }
 }
예제 #27
0
        public static RoomVM MapRoom(Room entity)
        {
            var res = new RoomVM()
            {
                RoomId         = entity.RoomId,
                AvailableSeats = entity.AvailableSeats,
                Name           = entity.Name,
                IsActive       = entity.IsActive,
                BuildingId     = entity.BuildingId
            };

            return(res);
        }
예제 #28
0
        public static Room MapRoomVM(RoomVM vm)
        {
            var res = new Room()
            {
                RoomId         = vm.RoomId,
                AvailableSeats = vm.AvailableSeats,
                Name           = vm.Name,
                IsActive       = vm.IsActive,
                BuildingId     = vm.BuildingId
            };

            return(res);
        }
        public ActionResult AddRoom()
        {
            var addRoomVM = new RoomVM
            {
                AllAmenities = roomService.GetAllAmenities().Select(a => new AmenityVM
                {
                    AmenityId   = a.AmenityId,
                    AmenityName = a.AmenityName
                }).ToList(),
            };

            return(View(addRoomVM));
        }
예제 #30
0
        /// <summary>
        /// Adds a new room to the collection
        /// </summary>
        /// <param name="RoomName">The name of the room</param>
        public RoomVM AddRoom(string RoomName = null)
        {
            bool HasRoomName = false || RoomName != null;

            RoomVM roomVM = new RoomVM(HasRoomName ? RoomName : "Room" + CurrentRoomNumber, CurrentRoomNumber);

            roomVM.PropertyChanged += Room_PropertyChanged;

            Rooms.Add(roomVM);

            CurrentRoomNumber++;

            return(roomVM);
        }