public async Task <List <Timeslot> > GetEventTimeslots(SpecialEventCategory category)
        {
            var orders = _db.Orders.Include(o => o.Pizzas).ThenInclude(p => p.Special).Where(a => a.CollectionDate.Date == category.EventDate.Date).ToList();

            List <Timeslot> timeslots = new List <Timeslot>();

            (int hour, int min)open   = (Convert.ToInt32(category.StartTime.Split(":")[0]), Convert.ToInt32(category.StartTime.Split(":")[1]));
            (int hour, int min)closed = (Convert.ToInt32(category.EndTime.Split(":")[0]), Convert.ToInt32(category.EndTime.Split(":")[1]));
            var openTime         = category.EventDate.AddHours(open.hour).AddMinutes(open.min);
            var closeTime        = category.EventDate.AddHours(closed.hour).AddMinutes(closed.min);
            var timeslotInterval = category.TimeslotInterval;
            var slot             = openTime;

            while (slot < closeTime)
            {
                if (IsEventSlotAvailable(orders, slot).Result)
                {
                    timeslots.Add(new Timeslot()
                    {
                        Date = slot, Time = slot.ToString("HH:mm")
                    });
                }
                slot = slot.AddMinutes(timeslotInterval);
            }
            return(timeslots);
        }
 public bool IsPotentiallyElegibleForFreeDelivery(SpecialEventCategory eventCategory, decimal totalPrice)
 {
     if (totalPrice >= eventCategory.FreeDeliveryThreshold)
     {
         return(true);
     }
     return(false);
 }
        public bool CheckFreeDeliveryEligibility(string postcode, SpecialEventCategory eventCategory)
        {
            var normalisedPostcode = postcode.Replace(" ", "").ToLower();

            if (eventCategory.LimitedPostcodes.Any(a => normalisedPostcode.StartsWith(a.ToLower().Replace(" ", ""))))
            {
                return(true);
            }
            return(false);
        }
 public async Task UpdateEvent(SpecialEventCategory cat)
 {
     _db.Update(cat);
     await _db.SaveChangesAsync();
 }