Exemplo n.º 1
0
        public IActionResult RequestChechOut(int id)
        {
            Inhabitant inhabitant = this.GetById(id);

            if (inhabitant == null)
            {
                return(new NotFoundResult());
            }

            TimeSpan usingTime = DateTime.Now - inhabitant.CheckIn;

            Room room = this.dbService.Context.Rooms
                        .Where(r => r.Id == inhabitant.RoomId).FirstOrDefault();
            RoomCategory category = room.Category;

            using (var db = this.dbService.Context)
            {
                db.Inhabitants.Remove(inhabitant);
                db.SaveChanges();
            }

            HttpContext.Response.StatusCode = StatusCodes.Status200OK;
            return(new JsonResult(new
            {
                Price = Logic.CalculatePrice(this.Config, category, usingTime)
            }));
        }
Exemplo n.º 2
0
        public static double CalculatePrice(IConfiguration config, RoomCategory category, TimeSpan interval)
        {
            double hours     = Math.Floor(interval.TotalHours) + 1;
            double roomPrice = RoomPrice(config, category);

            return(roomPrice * hours);
        }
Exemplo n.º 3
0
        public Room(int id, RoomCategory category)
        {
            Id       = id;
            Category = category;
            switch (Category)
            {
            case RoomCategory.Economy:
                Coast          = 50;
                SleepingPlaces = 4;
                break;

            case RoomCategory.Basic:
                Coast          = 100;
                SleepingPlaces = 3;
                break;

            case RoomCategory.Suite:
                Coast          = 200;
                SleepingPlaces = 2;
                break;

            case RoomCategory.PresidentSuite:
                Coast          = 300;
                SleepingPlaces = 2;
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutRoomCategories([FromRoute] Guid Id, [FromBody] RoomCategory obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Id != obj.Id)
            {
                return(BadRequest());
            }

            _context.Entry(obj).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 5
0
        public static string ToFriendlyName(this RoomCategory category)
        {
            switch (category)
            {
            case RoomCategory.ChatAndDiscussion: return("Chat and Discussion");

            case RoomCategory.PersonalSpace: return("Personal Spaces");

            case RoomCategory.Agencies: return("Agencies");

            case RoomCategory.Games: return("Games");

            case RoomCategory.BuildingAndDecoration: return("Building and Decoration");

            case RoomCategory.Trading: return("Trading");

            case RoomCategory.Party: return("Parties");

            case RoomCategory.RolePlaying: return("Role Playing");

            case RoomCategory.FansiteSquare: return("Fansite Squares");

            case RoomCategory.HelpCenters: return("Help Centers");

            default: return(category.ToString());
            }
        }
Exemplo n.º 6
0
        private void dgvRoom_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int roomId;

            if (int.TryParse(dgvRoom.Rows[e.RowIndex].Cells["Id"].Value.ToString(), out roomId))
            {
                tbNameRoom.Text = dgvRoom.Rows[e.RowIndex].Cells["Name"].Value.ToString();
                using (var DbContext = new AppContext())
                {
                    int BuildingId;
                    if (int.TryParse(dgvRoom.Rows[e.RowIndex].Cells["BuildingId"].Value.ToString(), out BuildingId))
                    {
                        Building building = DbContext.Buildings.Find(BuildingId);
                        cbbBuildingPickRoom.SelectedIndex = cbbBuildingPickRoom.FindString(building.Name);
                    }

                    int RoomCateId;
                    if (int.TryParse(dgvRoom.Rows[e.RowIndex].Cells["CateId"].Value.ToString(), out RoomCateId))
                    {
                        RoomCategory roomCategory = DbContext.RoomCategories.Find(RoomCateId);
                        cbbRoomCate.SelectedIndex = cbbRoomCate.FindString(roomCategory.Name);
                    }
                }
            }
            currentRoomId = roomId;
        }
 public void GetApartmentsByRoomCategory(ObservableCollection<Apartment> apartments,
         RoomCategory apartmentRoomCategory)
 {
     var allApartments = getApartments();
         var filteredApartments = allApartments.Where(p => p.ApartmentRoomNumber == apartmentRoomCategory).ToList();
         apartments.Clear();
         filteredApartments.ForEach(p => apartments.Add(p));
 }
Exemplo n.º 8
0
        public ActionResult DeleteConfirmed(int id)
        {
            RoomCategory roomCategory = db.RoomCategories.Find(id);

            db.RoomCategories.Remove(roomCategory);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public IActionResult Post([FromBody] RoomCategory roomCategory)
 {
     using (var scope = new TransactionScope())
     {
         _roomCategoryRepository.Create(roomCategory); scope.Complete();
         return(CreatedAtAction(nameof(Get), new { id = roomCategory.Id }, roomCategory));
     }
 }
Exemplo n.º 10
0
        protected void btnPublish_Click(object sender, EventArgs e)
        {
            if (this.txtDishName.Text.Trim().Length == 0)
            {
                this.ltaMsg.Text = "<script>alert('请输入房间名称!')</script>";
                return;
            }
            if (this.txtUnitPrice.Text.Trim().Length == 0)
            {
                this.ltaMsg.Text = "<script>alert('请输入房间价格!')</script>";
                return;
            }

            //封装对象
            RoomCategory room = new RoomCategory()
            {
                CategoryName = this.txtDishName.Text.Trim(),
                UnitPrice    = Convert.ToInt32(this.txtUnitPrice.Text.Trim()),
            };

            if (ViewState["CategoryId"] != null)//如果是修改则需要封装菜品编号
            {
                room.CategoryId = Convert.ToInt32(ViewState["CategoryId"]);
            }
            //提交数据
            try
            {
                if (this.btnPublish.Visible)
                {
                    if (!this.fulImage.HasFile)//如果是新增则需要选择图片
                    {
                        this.ltaMsg.Text = "<script>alert('请选择房间照片!')</script>";
                        return;
                    }
                    //提交菜品信息,并返回菜品编号
                    this.ltaMsg.Text = "<script>alert('" + room.CategoryName.Trim() + "')</script>";
                    int dishId = new DAL.RoomService().AddRoom(room);
                    //上传图片
                    this.UploadImage(dishId);
                    this.ltaMsg.Text = "<script>alert('添加成功')</script>";
                    //清空以前输入的内容
                    this.txtDishName.Text  = "";
                    this.txtUnitPrice.Text = "";
                }
                else
                {
                    new DAL.RoomService().ModifyRoom(room);
                    //上传图片
                    this.UploadImage(room.CategoryId);
                    // this.ltaMsg.Text = "<script>alert('修改成功')</script>";
                    Response.Write("<script>location.href='/Admin/Dishes/DishesManager.aspx';</script>");
                }
            }
            catch (Exception ex)
            {
                this.ltaMsg.Text = "<script>alert('添加失败!" + ex.Message + "')</script>";
            }
        }
Exemplo n.º 11
0
 public Room(int roomID, RoomCategory category, RoomType type, int x, int y, string doorLocations)
 {
     this.roomID        = roomID;
     this.category      = category;
     this.type          = type;
     this.x             = x;
     this.y             = y;
     this.doorLocations = doorLocations;
 }
Exemplo n.º 12
0
        public void ShouldFailBecauseOfNotPermitted()
        {
            using (UserManager <Client, int> manager = new ClientUserManager(new CustomUserStore(ctx)))
            {
                RoomCategory get = repo.GetRoomCategoryById(ctx.RoomCategorySet.FirstOrDefault(p => p.Title == "Cat1").Id, (int)manager.FindByEmail("*****@*****.**").DefaultHomeId);

                Assert.IsNull(get);
            }
        }
Exemplo n.º 13
0
        public void GetApartmentsByRoomCategory(ObservableCollection <Apartment> apartments,
                                                RoomCategory apartmentRoomCategory)
        {
            var allApartments      = getApartments();
            var filteredApartments = allApartments.Where(p => p.ApartmentRoomNumber == apartmentRoomCategory).ToList();

            apartments.Clear();
            filteredApartments.ForEach(p => apartments.Add(p));
        }
Exemplo n.º 14
0
        // GET: RoomCategory/Create
        public ActionResult Create()
        {
            RoomCategory roomCategory = new RoomCategory
            {
                getRoomType = roomCategoryPortal.getRoomType()
            };

            return(View(roomCategory));
        }
Exemplo n.º 15
0
        public RoomCategory Update(RoomCategory roomCategory)
        {
            roomCategory.Name = this.name;
            roomCategory.MaxNumberOfGuests = this.MaxNumberOfGuest;
            roomCategory.NumStartSurcharge = this.NumStartSurcharge;
            roomCategory.SurchargeRate     = this.SurchargeRate;
            roomCategory.UnitPrice         = this.UnitPrice;

            return(roomCategory);
        }
        public async Task <IActionResult> Create(RoomCategory roomCategory)
        {
            if (ModelState.IsValid)
            {
                await _service.CreateRoomCategory(roomCategory);

                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "RoomCategoryID,RoomCategory1,RoomFee")] RoomCategory roomCategory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(roomCategory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(roomCategory));
 }
Exemplo n.º 18
0
        public ActionResult Create(FormCollection collection)
        {
            RoomCategory roomCategory = new RoomCategory
            {
                type       = collection["type"],
                per_day_tk = Convert.ToInt32(collection["per_day_tk"])
            };

            roomCategoryPortal.insert(roomCategory);
            return(RedirectToAction("Index"));
        }
        public ActionResult Create(RoomCategory category)
        {
            if (ModelState.IsValid)
            {
                _roomCategoryDao.Create(category);
                return(RedirectToAction("Index", "RoomCategory"));
            }

            ViewBag.categories = _categories;
            return(View("Index"));
        }
        public static RoomCategoryModel MapRoomCatToRCModel(RoomCategory RoomCat)
        {
            var Cat = new RoomCategoryModel
            {
                Id          = RoomCat.Id,
                CatName     = RoomCat.Name,
                Description = RoomCat.Description
            };

            return(Cat);
        }
 public IActionResult Put(int id, [FromBody] RoomCategory roomCategory)
 {
     if (roomCategory != null)
     {
         using (var scope = new TransactionScope())
         {
             _roomCategoryRepository.Update(roomCategory); scope.Complete(); return(new OkResult());
         }
     }
     return(new NoContentResult());
 }
Exemplo n.º 22
0
        public ActionResult Create([Bind(Include = "RoomCategoryID,RoomCategory1,RoomFee")] RoomCategory roomCategory)
        {
            if (ModelState.IsValid)
            {
                db.RoomCategories.Add(roomCategory);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(roomCategory));
        }
Exemplo n.º 23
0
 public List <RoomDTO> GetAllRooms([FromQuery(Name = "minPrice")] int minPrice,
                                   [FromQuery(Name = "maxPrice")] int maxPrice,
                                   [FromQuery(Name = "beds")] int beds,
                                   [FromQuery(Name = "sort")] string sort,
                                   [FromQuery(Name = "sortDir")] bool sortDir,
                                   [FromQuery(Name = "roomCategory")] RoomCategory roomCategory,
                                   [FromQuery(Name = "from")] DateTime from,
                                   [FromQuery(Name = "hotelId")] int hotelId,
                                   [FromQuery(Name = "to")] DateTime to)
 {
     return(roomService.GetAllRooms(minPrice, maxPrice, beds, sort, sortDir, roomCategory, from, hotelId, to));
 }
        public static RoomCategoryModel MapRoomCategoryToRCModel(RoomCategory RoomCat)
        {
            var Cat = new RoomCategoryModel
            {
                Id          = RoomCat.Id,
                CatName     = RoomCat.Name,
                Description = RoomCat.Description
            };

            Cat.Rooms = RoomCat.Rooms.Select(r => MapRoomToRoomModel(r, Cat)).ToList();
            return(Cat);
        }
        public static RoomCategory MApRcToRoomCategory(RoomCategoryModel RoomCatModel)
        {
            var Cat = new RoomCategory
            {
                Id          = RoomCatModel.Id,
                Name        = RoomCatModel.CatName,
                Description = RoomCatModel.Description
            };

            Cat.Rooms = RoomCatModel.Rooms.Select(r => MapRoomModelToRom(r)).ToList();
            return(Cat);
        }
Exemplo n.º 26
0
        public IActionResult GetReservations(RoomCategory category, [FromQuery] DateTime?dateFrom)
        {
            if (category > RoomCategory.Suite)
            {
                return(NotFound());
            }
            var result = _db.Reservations
                         .Where(r => r.Room.RoomCategory == category && r.ReservationFrom >= (dateFrom ?? DateTime.MinValue))
                         .ToList();

            return(Ok(result));  // Liefert HTTP 200 mit den angegebenen Daten als JSON.
        }
Exemplo n.º 27
0
        public RoomCategory CreateModel()
        {
            var roomCategory = new RoomCategory();

            roomCategory.Name = this.name;
            roomCategory.MaxNumberOfGuests = this.MaxNumberOfGuest;
            roomCategory.NumStartSurcharge = this.NumStartSurcharge;
            roomCategory.SurchargeRate     = this.SurchargeRate;
            roomCategory.UnitPrice         = this.UnitPrice;

            return(roomCategory);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 修改房间
        /// </summary>
        /// <param name="room"></param>
        /// <returns></returns>
        public int ModifyRoom(RoomCategory room)
        {
            string sql = "UPDATE RoomCategory SET CategoryName=@CategoryName,UnitPrice=@UnitPrice WHERE CategoryId=@CategoryId";

            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@CategoryName", room.CategoryName),
                new SqlParameter("@UnitPrice", room.UnitPrice),
                new SqlParameter("@CategoryId", room.CategoryId)
            };
            return(SQLHelper.Update(sql, param));
        }
Exemplo n.º 29
0
        public async Task <IActionResult> PostRoomCategories([FromBody] RoomCategory obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _context.RoomCategories.Add(obj);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetRoomCategories", new { Id = obj.Id }, obj));
        }
Exemplo n.º 30
0
        public List <RoomDTO> GetAllRooms(decimal minPrice,
                                          decimal maxPrice,
                                          int beds,
                                          string sort,
                                          bool sortDir,
                                          RoomCategory roomCategory,
                                          DateTime from,
                                          int hotelId,
                                          DateTime to)
        {
            var rooms = context.Rooms.GetAll();

            if (hotelId != 0)
            {
                rooms = rooms.Where(r => r.HotelId == hotelId);
            }
            if (minPrice != 0)
            {
                rooms = rooms.Where(r => r.Price >= minPrice);
            }
            if (maxPrice != 0 && maxPrice > minPrice)
            {
                rooms = rooms.Where(r => r.Price <= maxPrice);
            }
            if (beds != 0)
            {
                rooms = rooms.Where(r => r.Beds == beds);
            }
            if (roomCategory != 0)
            {
                rooms = rooms.Where(r => r.Category == roomCategory);
            }
            if (from != null)
            {
                rooms = rooms.Where(r => r.Reservations.Where(res => res.EndDate > from || res.StartDate <= from).Count() == 0);
            }
            if (to != null && to > from)
            {
                rooms = rooms.Where(r => r.Reservations.Where(res => res.EndDate > from || res.StartDate > from).Count() == 0);
            }
            if (sort != null)
            {
                if (sort == "price" && sortDir)
                {
                    rooms = rooms.OrderBy(r => r.Price);
                }
                if (sort == "price" && !sortDir)
                {
                    rooms = rooms.OrderByDescending(r => r.Price);
                }
            }
            return(rooms.Select(r => r.ToRoomDTO()).ToList());
        }
Exemplo n.º 31
0
        /// <summary>
        /// 新增房间返回ID
        /// </summary>
        /// <param name="room"></param>
        /// <returns></returns>
        public int AddRoom(RoomCategory room)
        {
            string sql = "INSERT INTO RoomCategory(CategoryName,UnitPrice)";

            sql += "VALUES(@CategoryName,@UnitPrice);SELECT @@identity";
            SqlParameter[] param = new SqlParameter[]
            {
                new SqlParameter("@CategoryName", room.CategoryName),
                new SqlParameter("@UnitPrice", room.UnitPrice),
            };
            return(Convert.ToInt32(SQLHelper.GetSingleResult(sql, param)));
        }
Exemplo n.º 32
0
        /// <summary>
        /// Retourne le nombre de chambres d'une catégorie spécifiée.
        /// </summary>
        /// <param name="category">La catégorie spécifiée</param>
        /// <returns>Le nombre de chambres de la catégorie spécifiée</returns>
        public int getRoomsNb(RoomCategory category)
        {
            int roomsNb = 0;

            foreach (Room r in _rooms)
            {
                if (r.Category == category)
                {
                    roomsNb++;
                }
            }
            return roomsNb;
        }
 public Apartment(string apartmentId, RegionCategory apartmentRegion, CityCategory apartmentCity,
     RoomCategory apartmentRoomNumber, double apartmentRating, bool isApartmentAvailable, double apartmentPriceByNight)
 {
     ApartmentId = apartmentId;
     ApartmentRegion = apartmentRegion;
     ApartmentCity = apartmentCity;
     ApartmentRoomNumber = apartmentRoomNumber;
     ApartmentCoverImage = String.Format("Assets/ApartmentImages/CoverImages/{0}/FrontView.jpg", apartmentId);
     ApartmentInsideImage = String.Format("Assets/ApartmentImages/InsideImages/{0}/InsideView.jpg", apartmentId);
     ApartmentRating = apartmentRating;
     IsApartmentAvailable = isApartmentAvailable;
     ApartmentPriceByNight = apartmentPriceByNight;
 }
Exemplo n.º 34
0
 public StayLineItem(RoomCategory roomCategory, int quantity)
 {
     _roomCategory = roomCategory;
     _quantity = quantity;
 }