Ejemplo n.º 1
0
        public ActionResult Price(int id)
        {
            var IsAdminUser   = (User.IsInRole("Admin") || User.IsInRole("System")) ? true : false;
            var RoomIsCanEdit = IsAdminUser ? true : IsCanEdit;

            ViewBag.IsCanEdit = IsAdminUser ? true : IsCanEdit;
            ViewBag.RoomId    = id;
            ViewBag.Name      = _dbzh.Room.Find(id).Name;
            var PRDate = new PRDate();

            ViewBag.Begin = PRDate.Begin;
            ViewBag.End   = PRDate.End;
            return(View());
        }
Ejemplo n.º 2
0
        public ActionResult RoomPriceDate(PRDate model)
        {
            var BeginIsDate = IsDate(model.Begin);

            if (!BeginIsDate)
            {
                ModelState.AddModelError("Begin", "日期格式錯誤");
                return(View());
            }

            var EndIsDate = IsDate(model.End);

            if (!EndIsDate)
            {
                ModelState.AddModelError("End", "日期格式錯誤");
                return(View());
            }
            model.Edit();
            return(View());
        }
Ejemplo n.º 3
0
        public ActionResult Price(int id)
        {
            var IsAdminUser = (User.IsInRole("Admin") || User.IsInRole("System")) ? true : false;

            if (IsAdminUser)
            {
                ViewBag.IsCanEdit = true;
                ViewBag.RoomId    = id;
                var Room = (from room in _db.RoomZH
                            join hotel in _db.HotelZH on room.HOTELID equals hotel.ID
                            where room.ID == id
                            select room).FirstOrDefault();
                ViewBag.HotelId  = Room.HOTELID;
                ViewBag.MaxPrice = Room.MaxPrice.HasValue ? Room.MaxPrice.Value.ToString("#.##") : string.Empty;
                return(View());
            }
            else
            {
                var RoomIsCanEdit = IsAdminUser ? true : IsCanEdit;
                ViewBag.IsCanEdit = IsAdminUser ? true : IsCanEdit;
                ViewBag.RoomId    = id;
                var Room = (from room in _db.RoomZH
                            join hotel in _db.HotelZH on room.HOTELID equals hotel.ID
                            where room.ID == id && hotel.UserId == CurrentUser.Id
                            select room).FirstOrDefault();

                if (Room == null)
                {
                    return(RedirectToAction("", "Hotel"));
                }
                ViewBag.Name     = Room.Name;
                ViewBag.HotelId  = Room.HOTELID;
                ViewBag.MaxPrice = Room.MaxPrice.HasValue ? Room.MaxPrice.Value.ToString("#.##") : string.Empty;
                var PRDate = new PRDate();
                ViewBag.Begin = PRDate.Begin;
                ViewBag.End   = PRDate.End;
                return(View());
            }
        }
Ejemplo n.º 4
0
        public List <CalendarEvent> HotelImageUpload(int id)
        {
            var     Room  = new PRDate();
            var     Begin = DateTime.Parse(Room.Begin);
            var     End   = DateTime.Parse(Room.End);
            decimal Price = 0;
            List <CalendarEvent> Events = new List <CalendarEvent>();

            Price = _db.RoomZH.Find(id).Sell.Value;


            Events = (from room in _db.RoomPrice
                      where room.ROOMID == id
                      select new CalendarEvent
            {
                Start = room.Date,
                //End = room.Date.AddDays(1),
                Off = room.SaleOff,
                Price = room.Price,
                Quantity = room.Quantity
            }).ToList();

            DateTime             epoc   = new DateTime(1970, 1, 1);
            List <CalendarEvent> events = new List <CalendarEvent>();

            if (Events == null || Events.Count <= 0)
            {
                for (var date = Begin; date < End; date = date.AddDays(1.0))
                {
                    var beginDay = DateTime.Parse(date.ToShortDateString());
                    var endDay   = DateTime.Parse(date.ToShortDateString());
                    events.Add(new CalendarEvent {
                        Title    = "Event" + id.ToString(),
                        Start    = beginDay,
                        End      = endDay,
                        Price    = Price,
                        Off      = true,
                        Quantity = 0
                    });
                }
            }
            else
            {
                for (var date = Begin; date < End; date = date.AddDays(1.0))
                {
                    var     beginDay     = DateTime.Parse(date.ToShortDateString());
                    var     endDay       = DateTime.Parse(date.ToShortDateString());
                    var     Off          = false;
                    decimal CurrentPrice = 0;
                    int     Quantity     = 0;
                    var     Current      = Events.Where(o => o.Start == beginDay).FirstOrDefault();
                    if (Current != null)
                    {
                        CurrentPrice = Current.Price;
                        Off          = Current.Off;
                        Quantity     = Current.Quantity;
                    }
                    else
                    {
                        CurrentPrice = Price;
                        Off          = true;
                        Quantity     = 0;
                    }
                    events.Add(new CalendarEvent {
                        Title    = "Event" + id.ToString(),
                        Start    = beginDay,
                        End      = endDay,
                        Price    = CurrentPrice,
                        Off      = Off,
                        Quantity = Quantity
                    });
                }
            }
            return(events);
        }
Ejemplo n.º 5
0
        public ActionResult RoomPriceDate()
        {
            var PRDate = new PRDate();

            return(View(PRDate));
        }