Пример #1
0
        public ActionResult RecieveSMSMessage(string From, string Body)
        {
            var responseMessage = new MessagingResponse();

            responseMessage.Message("Hi, Thank you for using waiter! We Apreciate your feedback :)");

            From = From.Remove(0, 2);

            TableVisit currentTableVisit = db.TableVisits
                                           .Where(r => r.DinerPhone == From)
                                           .OrderByDescending(r => r.TableVisitId)
                                           .FirstOrDefault();

            if (Body == "y")
            {
                currentTableVisit.IsSatisfied = true;
                db.SaveChanges();
                analytics.CalculateWaitRate(currentTableVisit);
            }
            if (Body == "n")
            {
                currentTableVisit.IsSatisfied = false;
                db.SaveChanges();
                analytics.CalculateWaitRate(currentTableVisit);
            }

            return(TwiML(responseMessage));
        }
Пример #2
0
        public ActionResult DeleteConfirmed(int id)
        {
            TableVisit tableVisit = db.TableVisits.Find(id);

            db.TableVisits.Remove(tableVisit);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #3
0
        private void WarnDiner(int TableVisitId)
        {
            TableVisit currentTableVisit = db.TableVisits.Find(TableVisitId);

            messenger.SendSMSMessage(currentTableVisit.DinerPhone, "Your Table will be ready Soon!");
            currentTableVisit.IsWarned = true;

            //return RedirectToAction("Index","TableVisit", new { restaurantId = currentTableVisit.RestaurantId });
        }
Пример #4
0
        public ActionResult SendTableReadyNotification(int TableVisitId)
        {
            TableVisit currentTableVisit = db.TableVisits.Find(TableVisitId);

            messenger.SendSMSMessage(currentTableVisit.DinerPhone, "Your Table is ready!");
            currentTableVisit.GracePeriodStart = DateTime.Now;
            ViewBag.infoMessage = "Your Table Notification has been sent.";
            db.SaveChanges();
            return(RedirectToAction("Index", "TableVisit", new { restaurantId = currentTableVisit.RestaurantId }));
        }
Пример #5
0
 public ActionResult Edit([Bind(Include = "TableVisitId,DinerName,DinerPhone,CreatedOn,WaitMinutes,WeatherConditionId,IsHostEntry,IsSatisfied,PartySize,IsWarned,GracePeriodStart,IsNoShow,IsActive")] TableVisit tableVisit)
 {
     if (ModelState.IsValid)
     {
         db.Entry(tableVisit).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.WeatherConditionId = new SelectList(db.WeatherConditions, "WeatherConditionId", "WeatherDescription", tableVisit.WeatherConditionId);
     return(View(tableVisit));
 }
Пример #6
0
        public ActionResult RemoveFromLine(TableVisit currentTableVisit)
        {
            int        currentRestaurantId = currentTableVisit.RestaurantId;
            Restaurant currentResaurant    = db.Restaurants.Find(currentRestaurantId);

            if (currentTableVisit.IsActive)
            {
                messenger.SendSMSMessage(currentTableVisit.DinerPhone, "Thank you for using Waiter." + currentResaurant.RestaurantName + " had a table ready for you  earlier than stated. Did you enjoy our service. (Type 'y' for yes or 'n' for no)");
                ViewBag.infoMessage        = currentTableVisit.DinerName + "'s reservation has been removed due to grace period reservation.";
                currentTableVisit.IsActive = false;
            }
            return(RedirectToAction("Index", "TableVisit", new { restaurantId = currentTableVisit.RestaurantId }));
        }
Пример #7
0
        // GET: TableVisit/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TableVisit tableVisit = db.TableVisits.Find(id);

            if (tableVisit == null)
            {
                return(HttpNotFound());
            }
            return(View(tableVisit));
        }
Пример #8
0
        public ActionResult HostRemoveFromLine(int tableVisitId)
        {
            TableVisit currentTableVisit   = db.TableVisits.Find(tableVisitId);
            int        currentRestaurantId = currentTableVisit.RestaurantId;
            Restaurant currentResaurant    = db.Restaurants.Find(currentRestaurantId);

            if (currentTableVisit.IsActive)
            {
                messenger.SendSMSMessage(currentTableVisit.DinerPhone, "Thank you for using Waiter." + currentResaurant.RestaurantName + " had a table ready for you earlier than stated. Did you enjoy our service. (Type 'y' for yes or 'n' for no)");
                ViewBag.infoMessage        = "You have Removed " + currentTableVisit.DinerName + "'s reservation.";
                currentTableVisit.IsActive = false;
            }
            db.SaveChanges();
            return(RedirectToAction("Index", "TableVisit", new { restaurantId = currentRestaurantId }));
        }
Пример #9
0
        // GET: TableVisit/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            TableVisit tableVisit = db.TableVisits.Find(id);

            if (tableVisit == null)
            {
                return(HttpNotFound());
            }
            ViewBag.WeatherConditionId = new SelectList(db.WeatherConditions, "WeatherConditionId", "WeatherDescription", tableVisit.WeatherConditionId);
            return(View(tableVisit));
        }
Пример #10
0
        //public ActionResult Create([Bind(Include = "TableVisitId,DinerName,DinerPhone,CreatedOn,WaitMinutes,WeatherConditionId,IsHostEntry,IsSatisfied,PartySize,IsWarned,GracePeriodStart,IsNoShow,IsActive")] TableVisit tableVisit)
        public ActionResult Create(int restaurantId, bool isHostEntry, string dinerName, string dinerPhone, int partySize)
        {
            //TO DO: ADD VALIDATION USING THE IF STATEMENT BELOW:
            //if (ModelState.IsValid)
            //{
            //}

            var restaurant = db.Restaurants
                             .Include(r => r.TableVisits)
                             .Include(r => r.Address.City)
                             .Where(r => r.RestaurantId == restaurantId)
                             .FirstOrDefault();

            string           cityName         = restaurant.Address.City.Name;
            WeatherCondition weatherCondition = new WeatherCondition(cityName);

            TableVisit tableVisit = new TableVisit();

            tableVisit.DinerName        = dinerName;
            tableVisit.DinerPhone       = dinerPhone;
            tableVisit.CreatedOn        = DateTime.Now;
            tableVisit.WeatherCondition = weatherCondition;
            tableVisit.IsHostEntry      = isHostEntry;
            tableVisit.PartySize        = partySize;
            tableVisit.IsWarned         = false;
            tableVisit.IsNoShow         = false;
            tableVisit.IsActive         = true;
            tableVisit.RestaurantId     = restaurantId;
            db.TableVisits.Add(tableVisit);
            db.SaveChanges();

            restaurant.TableVisits.Add(tableVisit);
            db.SaveChanges();
            if (isHostEntry)
            {
                TempData["tableVisitMessage"] = "Added " + dinerName + " to the wait list.";
                return(RedirectToAction("Index", "TableVisit", new { restaurantId = restaurantId }));
            }
            return(RedirectToAction("DinerConfirmation", "Restaurant", new { restaurantId = restaurantId }));
        }
Пример #11
0
        public void CalculateWaitRate(TableVisit currentTableVisit)
        {
            Restaurant currentRestaurant = db.Restaurants.Find(currentTableVisit.RestaurantId);
            int        totalRatings      = 0;
            int        yesTotal          = 0;

            foreach (var customer in db.TableVisits)
            {
                if (customer.RestaurantId == currentRestaurant.RestaurantId)
                {
                    totalRatings++;
                    if (customer.IsSatisfied == true)
                    {
                        yesTotal++;
                    }
                }
            }

            int WaitRate = (yesTotal / totalRatings) * 100;

            WaitRate rate = db.WaitRate.Find(currentRestaurant.WaitRateId);

            rate.WaitRatePercentage = WaitRate;
        }
Пример #12
0
        protected override void Seed(WaiterRestaurantApplication.Models.ApplicationDbContext context)
        {
            //Seed States table with all US States
            string seedFile = "~/CSV/SeedData/";//states.csv removed from end of seedFile
            string filePath = GetMapPath(seedFile);


            //alex's file path////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
            //filePath = @"C:\Users\Andross\Desktop\school_projects\C#\WaiterRestaurantApplication\WaiterRestaurantApplication\CSV\SeedData\";
            //end of alex's stuff/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

            bool fileExists = File.Exists(filePath + "states.csv");

            if (fileExists)
            {
                List <State> states = new List <State>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "states.csv"))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    State state;
                    while (!parser.EndOfData)
                    {
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        state              = new State();
                        state.Name         = fields[0];
                        state.Abbreviation = fields[1];
                        states.Add(state);
                    }
                }
                context.States.AddOrUpdate(c => c.Abbreviation, states.ToArray());
                context.SaveChanges();
            }

            City Milwaukee = new City();

            Milwaukee.CityId = 1;
            Milwaukee.Name   = "Milwaukee";

            ZipCode five3202 = new ZipCode();

            five3202.ZipCodeId = 1;
            five3202.Number    = "53202";

            context.Cities.Add(Milwaukee);
            context.ZipCodes.Add(five3202);

            fileExists = File.Exists(filePath + "addresses.csv");
            if (fileExists)
            {
                List <Address> addresses = new List <Address>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "addresses.csv"))
                {
                    int whileCount = 0;
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    Address address;
                    while (!parser.EndOfData)
                    {
                        whileCount += 1;
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        address           = new Address();
                        address.AddressId = whileCount;
                        address.StreetOne = fields[0];
                        address.StreetTwo = fields[1];
                        address.CityId    = Convert.ToInt32(fields[2]);
                        address.StateId   = Convert.ToInt32(fields[3]);
                        address.ZipCodeId = Convert.ToInt32(fields[4]);
                        address.Lat       = float.Parse(fields[5]);
                        address.Lng       = float.Parse(fields[6]);
                        addresses.Add(address);
                    }
                }
                context.Addresses.AddOrUpdate(addresses.ToArray());
                context.SaveChanges();
            }

            Random random = new Random();

            fileExists = File.Exists(filePath + "restaurants.csv");
            if (fileExists)
            {
                List <Restaurant> restaurants = new List <Restaurant>();
                List <WaitRate>   waitRates   = new List <WaitRate>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "restaurants.csv"))
                {
                    int whileCount = 0;
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    Restaurant restaurant;
                    WaitRate   waitRate;
                    while (!parser.EndOfData)
                    {
                        whileCount += 1;
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        restaurant = new Restaurant();
                        waitRate   = new WaitRate();
                        //add waitrate to list and save to context
                        restaurant.RestaurantId        = whileCount;
                        restaurant.RestaurantName      = fields[0];
                        restaurant.AddressId           = Convert.ToInt32(fields[1]);
                        restaurant.OpenTime            = fields[2];
                        restaurant.CloseTime           = fields[3];
                        restaurant.IsOpen              = true;
                        restaurant.PeopleBeforeWarning = Convert.ToInt32((fields[5]));
                        restaurant.GracePeriodMinutes  = Convert.ToInt32(fields[6]);
                        restaurant.CurrentWaitMinutes  = Convert.ToInt32(fields[7]);
                        restaurant.WaitRateId          = whileCount;
                        waitRate.WaitRateId            = whileCount;
                        waitRate.WaitRatePercentage    = random.Next(5, 95);
                        restaurants.Add(restaurant);
                        waitRates.Add(waitRate);
                    }
                }
                context.Restaurants.AddOrUpdate(restaurants.ToArray());
                context.WaitRate.AddOrUpdate(waitRates.ToArray());
                context.SaveChanges();
            }

            fileExists = File.Exists(filePath + "weatherConditions.csv");
            if (fileExists)
            {
                List <WeatherCondition> weatherConditions = new List <WeatherCondition>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "weatherConditions.csv"))
                {
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    WeatherCondition weatherCondition;
                    while (!parser.EndOfData)
                    {
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        weatherCondition = new WeatherCondition();
                        weatherCondition.WeatherConditionId = Convert.ToInt32(fields[0]);
                        weatherCondition.Temperature        = Convert.ToInt32(fields[1]);
                        weatherCondition.WeatherDescription = fields[2];
                        weatherConditions.Add(weatherCondition);
                    }
                }
                context.WeatherConditions.AddOrUpdate(weatherConditions.ToArray());
                context.SaveChanges();
            }

            fileExists = File.Exists(filePath + "tableVisits.csv");
            if (fileExists)
            {
                List <TableVisit> tableVisits = new List <TableVisit>();
                using (TextFieldParser parser = new TextFieldParser(filePath + "tableVisits.csv"))
                {
                    //adjust datetime inputs here for week leading up to presentation (as long as the week doesn't cross into a month)
                    int year       = 2018;
                    int month      = 1;
                    int startDay   = 12;
                    int endDay     = 18;
                    int whileCount = startDay;
                    parser.TextFieldType = FieldType.Delimited;
                    parser.SetDelimiters(",");
                    TableVisit tableVisit;
                    while (!parser.EndOfData)
                    {
                        string[] fields = parser.ReadFields();
                        if (fields.Any(x => x.Length == 0))
                        {
                            Console.WriteLine("We found an empty value in your CSV. Please check your file and try again.\nPress any key to return to main menu.");
                            Console.ReadKey(true);
                        }
                        tableVisit = new TableVisit();
                        tableVisit.TableVisitId       = Convert.ToInt32(fields[0]);
                        tableVisit.WaitMinutes        = Convert.ToInt32(fields[1]);
                        tableVisit.WeatherConditionId = Convert.ToInt32(fields[2]);
                        if (Convert.ToInt32(fields[3]) == 1)
                        {
                            tableVisit.IsSatisfied = true;
                        }
                        else
                        {
                            tableVisit.IsSatisfied = false;
                        }
                        tableVisit.PartySize    = Convert.ToInt32(fields[4]);
                        tableVisit.RestaurantId = Convert.ToInt32(fields[5]);
                        if (Convert.ToInt32(fields[6]) == 1)
                        {
                            tableVisit.IsHostEntry = true;
                        }
                        else
                        {
                            tableVisit.IsHostEntry = false;
                        }

                        tableVisit.IsWarned  = true;
                        tableVisit.IsActive  = false;
                        tableVisit.CreatedOn = new DateTime(year, month, whileCount);

                        tableVisits.Add(tableVisit);
                        whileCount += 1;
                        if (whileCount > endDay)
                        {
                            whileCount = startDay;
                        }
                    }
                }
                context.TableVisits.AddOrUpdate(tableVisits.ToArray());
                //context.SaveChanges();
            }

            int amountOfTableVisitsToAddForToday    = 10;
            WeatherCondition  weatherConditionToday = null;
            List <TableVisit> tableVisitsToday      = new List <TableVisit>();
            int tableVisitsPrimaryKey = 22; //check tableVisits.csv, keep this count 1 above the entries in the csv.

            while (amountOfTableVisitsToAddForToday > 0)
            {
                amountOfTableVisitsToAddForToday -= 1;
                if (weatherConditionToday == null)
                {
                    weatherConditionToday = new WeatherCondition("Milwaukee");
                    context.WeatherConditions.Add(weatherConditionToday);
                    context.SaveChanges();
                }
                TableVisit tableVisit = new TableVisit();

                tableVisit.TableVisitId       = tableVisitsPrimaryKey;
                tableVisitsPrimaryKey        += 1;
                tableVisit.WaitMinutes        = random.Next(10, 35);
                tableVisit.WeatherConditionId = 5;  //check weatherConditions.csv, keep this count 1 above the entries in the csv.
                if (tableVisit.WaitMinutes % 3 == 1)
                {
                    tableVisit.IsSatisfied = false;
                }
                else
                {
                    tableVisit.IsSatisfied = true;
                }
                tableVisit.PartySize    = random.Next(2, 11);
                tableVisit.RestaurantId = 1;
                if (tableVisit.PartySize % 2 == 0)
                {
                    tableVisit.IsHostEntry = true;
                }
                else
                {
                    tableVisit.IsHostEntry = false;
                }
                tableVisit.IsWarned  = true;
                tableVisit.IsActive  = false;
                tableVisit.CreatedOn = DateTime.Now;

                tableVisitsToday.Add(tableVisit);
                //context.SaveChanges();
            }
            context.TableVisits.AddOrUpdate(tableVisitsToday.ToArray());

            //Seed the subscription types
            SubscriptionType monthlySubscription = new SubscriptionType();

            monthlySubscription.Name  = "Monthly Subscription";
            monthlySubscription.Price = 9.99d;

            SubscriptionType annualSubscription = new SubscriptionType();

            annualSubscription.Name  = "Annual Subscription";
            annualSubscription.Price = 110.00d;

            context.SubscriptionTypes.Add(monthlySubscription);
            context.SubscriptionTypes.Add(annualSubscription);

            context.SaveChanges();
        }
Пример #13
0
        private int calculateWaitTime(TableVisit currentTableVisit)
        {
            DateTime gracePeriod = currentTableVisit.GracePeriodStart.Value;

            return((int)(gracePeriod.Subtract(currentTableVisit.CreatedOn).TotalMinutes));
        }