public IActionResult Create()
        {
            RoomCreateViewModel model = null;

            var OnlineUser = _userManager.GetUserAsync(HttpContext.User).Result;

            if (OnlineUser == null && !(_userManager.IsInRoleAsync(OnlineUser, "Manager").Result))
            {
            }
            var hotel = _repository.GetHotelByManagerId(OnlineUser.Id, true);
            //var hotel = _repository.GetHotels();
            var floors = _repository.getHotelFloorsbyHotelId(hotel.HotelId);

            if (hotel != null)
            {
                model = new RoomCreateViewModel()
                {
                    HotelId   = hotel.HotelId,
                    HotelName = hotel.HotelName,
                    Floors    = floors.Select(p => new SelectListItem()
                    {
                        Text  = p.FloorName,
                        Value = p.HotelFloorsId.ToString()
                    }).ToList(),
                };
            }
            return(PartialView(model));
        }
Esempio n. 2
0
        public IActionResult Create(RoomCreateViewModel room)
        {
            _sheduleService.CreateRoom(room);
            var data = GetItems(null);

            return(PartialView("ItemsTable", data));
        }
Esempio n. 3
0
        public IActionResult Create(RoomCreateViewModel model)
        {
            if (context.Rooms.FirstOrDefault(r => r.Number == model.Number) != null)
            {
                ModelState.AddModelError("Number", "There is already created room with this number.");
            }

            if (ModelState.IsValid)
            {
                Room room = new Room()
                {
                    Id         = Guid.NewGuid().ToString(),
                    Capacity   = model.Capacity,
                    Type       = (RoomType)model.Type,
                    AdultPrice = model.AdultPrice,
                    ChildPrice = model.ChildPrice,
                    Number     = model.Number,
                    IsFree     = true
                };

                context.Rooms.AddAsync(room);
                context.SaveChanges();

                return(Redirect("~/Room/Details/" + room.Id));
            }

            return(View(model));
        }
        public IActionResult Update(int id)
        {
            int count = 0;

            RoomCreateViewModel model = null;
            //var hotel = _repository.GetHotels();
            //var floors = _repository.GetFloors();
            //var hotel = _repository.GetHotels();
            var room = _repository.RoomById(id);

            if (room != null)
            {
                model = new RoomCreateViewModel()
                {
                    RoomId        = room.HotelRoomId,
                    Description   = room.Description,
                    OcupancyLimit = room.OcupancyLimit,
                    RoomName      = room.RoomName,
                    RoomNo        = room.RoomNo,
                    RoomType      = room.HotelRoomType.RoomType
                };
            }

            return(PartialView(model));
        }
Esempio n. 5
0
        public ActionResult Create(int id)
        {
            var Hotel = _db.Hotel.Find(id);

            if (Hotel == null || Hotel.UserId != CurrentUser.Id)
            {
                return(RedirectToAction("Login", "Account"));
            }

            var model = new RoomCreateViewModel();
            //model.Bonus = 300;
            var ImgKey = Guid.NewGuid().GetHashCode().ToString("x");

            model.ImgKey    = ImgKey;
            model.HotelId   = id;
            model.Enabled   = true;
            model.Quantity  = 1;
            model.BedAmount = 1;
            model.Notice    = new HtmlContent("/Views/Room/InformationTemp.html").Text;

            ViewBag.BedType = new CodeFiles().GetBedsSelectList();


            ViewBag.RoomType = new CodeFiles().GetRoomsSelectList();
            return(View(model));
        }
Esempio n. 6
0
        public void CreateRoom(RoomCreateViewModel room)
        {
            _roomRepo.create(new RoomModel()
            {
                Name = room.Name
            });

            _roomRepo.SaveChanges();
        }
Esempio n. 7
0
        public IActionResult Create(RoomCreateViewModel model)
        {
            Room room = _mapper.Map <Room>(model);

            room.UserId = _userManager.GetUserId(User);

            _roomRepository.CreateRoom(room);
            _roomRepository.Savechanges();

            return(RedirectToAction("Index", "Socket"));
        }
Esempio n. 8
0
        public ViewResult Create(int id)
        {
            Branch branch = _branchRepository.GetBranch(id);
            RoomCreateViewModel roomCreateViewModel = new RoomCreateViewModel
            {
                BranchId = branch.Id,
                Name     = branch.Name
            };

            return(View(roomCreateViewModel));
        }
Esempio n. 9
0
        private string ProcessUploadedFile(RoomCreateViewModel model)
        {
            string uniqueFileName = null;

            if (model.Photo != null)
            {
                string uploadsFolder = Path.Combine(hostingEnvironment.WebRootPath, "Images");
                uniqueFileName = Guid.NewGuid().ToString() + "_" + model.Photo.FileName;
                string filePath = Path.Combine(uploadsFolder, uniqueFileName);
                using (var fileStream = new FileStream(filePath, FileMode.Create))
                {
                    model.Photo.CopyTo(fileStream);
                }
            }

            return(uniqueFileName);
        }
Esempio n. 10
0
        public IActionResult Create(RoomCreateViewModel model)
        {
            for (int i = 10; i < (model.Floor + 1) * 10; i++)
            {
                Room newRoom = new Room
                {
                    BranchId   = model.BranchId,
                    Floor      = i / 10,
                    RoomNumber = i,
                    RoomStatus = RoomStatus.Free,
                    Star       = model.Star
                };

                _roomRepository.Add(newRoom);
            }

            return(RedirectToAction("details", "branch", new { id = model.BranchId }));
        }
        public async Task <IActionResult> CreateRoom(RoomCreateViewModel room)
        {
            if (!this.ModelState.IsValid || room.Image == null)
            {
                return(this.RedirectToAction(nameof(CreateRoom)));
            }

            var uniqueFileName = GetUniqueFileName(room.Image.FileName);
            var uploads        = Path.Combine(environment.WebRootPath, "images\\Rooms");
            var filePath       = Path.Combine(uploads, uniqueFileName);

            room.Image.CopyTo(new FileStream(filePath, FileMode.Create));
            var parsedRoom = this.mapper.Map <Room>(room);

            await this.hotelService.CreateRoom(parsedRoom, uniqueFileName);

            return(this.RedirectToAction(nameof(RoomList)));
        }
Esempio n. 12
0
        public IActionResult Create(RoomCreateViewModel model)
        {
            if (ModelState.IsValid)
            {
                string uniqueFileName = ProcessUploadedFile(model);
                Room   newRoom        = new Room
                {
                    Type        = model.Type,
                    RoomNumber  = model.RoomNumber,
                    Price       = model.Price,
                    Description = model.Description,
                    PhotoPath   = uniqueFileName
                };

                _roomRepository.Add(newRoom);

                return(RedirectToAction("details", new { id = newRoom.RoomID }));
            }
            return(View());
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            List <RoomTypeViewModel> list  = new List <RoomTypeViewModel>();
            RoomCreateViewModel      model = null;
            var roomtypes = _context.hotelRoomTypes;

            if (roomtypes != null)
            {
                model = new RoomCreateViewModel()
                {
                    Roomtypes = roomtypes.Select(p => new SelectListItem()
                    {
                        Text  = p.RoomType,
                        Value = p.HotelRoomTypeId.ToString()
                    }).ToList(),
                };
            }


            return(View(model));
        }
        public IActionResult Update(RoomCreateViewModel model)
        {
            bool   Status  = false;
            string Message = string.Empty;

            if (ModelState.IsValid)
            {
                var hotel = new HotelRoom()
                {
                    //RoomType = model.RoomType,
                    OcupancyLimit = model.OcupancyLimit,
                    HotelFloors   = model.HotelFloors,
                    Description   = model.Description,
                    IsBooked      = false,
                    Hotel         = _repository.HotelById(model.HotelId),
                    HotelRoomType = _context.hotelRoomTypes.
                                    FirstOrDefault(p => p.HotelRoomTypeId == model.RoomTypeId),
                    RoomName = model.RoomName,
                    RoomNo   = model.RoomNo
                };

                _repository.Update(hotel);

                if (_repository.SaveChange())
                {
                    return(RedirectToAction("Index", new { area = "Manager", controller = "HotelRooms" }));
                }
                else
                {
                    Status  = false;
                    Message = "Error inserting /Creating Course";
                }
            }
            else
            {
                ModelState.AddModelError("", "invalid / incomplete data");
            }
            //return Json(new { status = Status, message = Message });
            return(View());
        }
Esempio n. 15
0
        public ActionResult Edit(RoomCreateViewModel model)
        {
            var room = _db.Room.Find(model.ID);

            model.Creator = CurrentUser.Id;
            if (room == null || room.Hotel.UserId != CurrentUser.Id)
            {
                return(RedirectToAction("", "Home"));
            }
            try
            {
                model.Edit();
            }
            catch (Exception ex) {
                ViewBag.BedType  = new CodeFiles().GetBedsSelectList(model.BedType);
                ViewBag.RoomType = new CodeFiles().GetRoomsSelectList(model.RoomType);
                ModelState.AddModelError("", ex.Message.ToString());
                return(View());
            }

            return(RedirectToAction("Edit", new { id = model.ID }));
        }
 public async Task <IActionResult> Create(RoomCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         Room room = new Room()
         {
             Name = model.Name, Capacity = model.Capacity
         };
         if (await _dbContext.AddAsync(room) != null)
         {
             if (await _dbContext.SaveChangesAsync() > 0)
             {
                 return(RedirectToAction("Index", "Rooms"));
             }
         }
     }
     else
     {
         ModelState.AddModelError("", "Please, try again");
     }
     return(RedirectToAction("Index", "Rooms"));
 }
Esempio n. 17
0
        public ActionResult Create(RoomCreateViewModel roomCreateInfo)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    int currentUserID = ((User)HttpContext.Items["currentUser"]).UserID;
                    using (var db = new RealtimeChatDB())
                    {
                        var newRoom = db.Rooms.Create();
                        newRoom.RoomName        = roomCreateInfo.RoomName;
                        newRoom.ShowName        = roomCreateInfo.ShowName;
                        newRoom.RoomDescription = roomCreateInfo.Description;
                        newRoom.CreatorID       = ((User)HttpContext.Items["currentUser"]).UserID;
                        db.Rooms.Add(newRoom);

                        var newMember = db.RoomMembers.Create();
                        newMember.UserID      = ((User)HttpContext.Items["currentUser"]).UserID;
                        newMember.RoomID      = newRoom.RoomID;
                        newMember.MemberLevel = 2;
                        db.RoomMembers.Add(newMember);

                        db.SaveChanges();

                        TempData["successMessage"] = "You have successfully created a room";
                        return(RedirectToAction("Index"));
                    }
                }
                else
                {
                    return(View());
                }
            }
            catch
            {
                return(View());
            }
        }
Esempio n. 18
0
        public ActionResult Create(RoomCreateViewModel model)
        {
            var RoomImage = new List <RoomImage>();
            var PersonBed = new List <int>();

            RoomImage             = (List <RoomImage>)Session[model.ImgKey];
            Session[model.ImgKey] = RoomImage;

            ViewBag.RoomImage = RoomImage;


            model.UserId = CurrentUser.Id;

            if (ModelState.IsValid)
            {
                model.Create();
                return(RedirectToAction("Index", new { id = model.HotelId }));
            }

            ViewBag.BedType  = new CodeFiles().GetBedsSelectList();
            ViewBag.RoomType = new CodeFiles().GetRoomsSelectList();
            return(View(model));
        }
Esempio n. 19
0
        public IActionResult Create()
        {
            RoomCreateViewModel model = new RoomCreateViewModel();

            return(View(model));
        }
Esempio n. 20
0
        public IActionResult CreateModal()
        {
            var data = new RoomCreateViewModel();

            return(PartialView(data));
        }