コード例 #1
0
        public ActionResult TeeTimeScheduler()
        {
            TeeTimesForDay ttd = new TeeTimesForDay();

            ttd.SelectableTimes = m_teeTimeBO.GatherDates(DateTime.Now);
            return(PartialView(ttd));
        }
コード例 #2
0
        public async Task <ActionResult> ScheduleATeeTime(DateTime date)
        {
            TeeTimesForDay ttdy = new TeeTimesForDay();

            ttdy = await m_teeTimeBO.DailyTeeTimes(date);

            return(PartialView(ttdy));
        }
コード例 #3
0
        public async Task <ActionResult> ScheduleTeeTime()
        {
            //We want to build the model to pass to the data object
            TeeTimesForDay ttd = new TeeTimesForDay();

            ttd = await m_teeTimeBO.DailyTeeTimes(DateTime.Now);

            return(View(ttd));
        }
コード例 #4
0
ファイル: TeeTimeBO.cs プロジェクト: adrielp/SquawCreek
        public async Task <TeeTimesForDay> DailyTeeTimes(DateTime selected)
        {
            TeeTimesForDay         ttd      = new TeeTimesForDay();
            List <TeeTimesPerSlot> ttpsList = new List <TeeTimesPerSlot>();

            ttd.CurrentDate = selected;
            DateTime holder = new DateTime();

            //loop to create slots
            for (int i = 0; i < 25; i++)
            {
                TimeSpan slotTime;

                if (i < 1)
                {
                    TeeTimesPerSlot ttps = new TeeTimesPerSlot();
                    slotTime             = new TimeSpan(7, 0, 0);
                    ttps.ScheduleTime    = selected.Date + slotTime;
                    holder               = ttps.ScheduleTime;
                    ttps.Id              = Guid.Empty;
                    ttps.Paid            = false;
                    ttps.BookedBy        = string.Empty;
                    ttps.Created         = DateTime.Now;
                    ttps.NumberOfPlayers = 1;
                    ttps.Member          = false;
                    ttps.Cart            = false;
                    ttpsList.Add(ttps);
                }
                else
                {
                    TeeTimesPerSlot ttps = new TeeTimesPerSlot();
                    holder               = holder.AddMinutes(30);
                    ttps.ScheduleTime    = holder;
                    holder               = ttps.ScheduleTime;
                    ttps.Id              = Guid.Empty;
                    ttps.Paid            = false;
                    ttps.BookedBy        = string.Empty;
                    ttps.Created         = DateTime.Now;
                    ttps.NumberOfPlayers = 1;
                    ttps.Member          = false;
                    ttps.Cart            = false;
                    ttpsList.Add(ttps);
                }
            }

            //now you need to loop through and see what slots are taken
            List <TeeTimesPerSlot> FinalPull = new List <TeeTimesPerSlot>();

            using (SquawCreekDeVryEntities db = new SquawCreekDeVryEntities())
            {
                foreach (TeeTimesPerSlot slot in ttpsList)
                {
                    if (db.TeeTimes.Any(x => x.ScheduleTime.ToString() == slot.ScheduleTime.ToString()))
                    {
                        var item = db.TeeTimes.Where(x => x.ScheduleTime == slot.ScheduleTime).Select(x => new TeeTimesPerSlot
                        {
                            ScheduleTime    = x.ScheduleTime.Value,
                            Id              = x.Id,
                            Paid            = x.Paid.Value,
                            BookedBy        = x.BookedBy,
                            Created         = x.Created.Value,
                            NumberOfPlayers = x.NumberOfPlayers.Value,
                            Member          = x.Member.Value,
                            Cart            = x.Cart.Value
                        }).FirstOrDefault();

                        FinalPull.Add(item);
                    }
                    else
                    {
                        FinalPull.Add(slot);
                    }
                }
            }
            ttd.SelectableTimes = GatherDates(DateTime.Now);
            ttd.TeeTimesBySlot  = FinalPull;
            return(ttd);
        }