public ActionResult Start(GroupInfoModel gim, ShoppingCart cart, BrowseHistory bh)
        {
            string approxtime = string.Empty;
            string mysAddress = gim.Address + " " + gim.ZipCode;

            string[] s = base.GetAddressCityState(gim.Address);
            ViewBag.ValidateAddress = string.Empty;
            List <BizInfo> lb = new List <BizInfo>();

            if (string.IsNullOrEmpty(gim.Address) || string.IsNullOrEmpty(gim.ZipCode) || gim.ZipCode.Length != 5 || string.IsNullOrEmpty(s[0]) || string.IsNullOrEmpty(s[1]) || string.IsNullOrEmpty(s[2]))
            {
                ViewBag.ValidateAddress = "Oops, feel like something wrong with you address. Please check it and try again.";
            }
            else
            {
                bh.Address          = s[0];
                bh.City             = s[1];
                bh.State            = s[2];
                bh.Zip              = gim.ZipCode;
                bh.AddressCityState = s[0] + ", " + s[1] + ", " + s[2];
                List <BizInfo> lbi = BizInfoRepository.GetBizInfoByZip(gim.ZipCode, true);
                foreach (var b in lbi)
                {
                    decimal st = SearchFilter.GetDistance(mysAddress, b.BizAddressString, out approxtime);
                    if (st >= 0 && st <= b.DeliveryRadius && b.Delivery)
                    {
                        lb.Add(b);
                    }
                }
                bh.GroupBizOption = lb;
            }
            gim.LBizInfo = lb;
            gim.Cart     = cart;
            return(PartialView(gim));
        }
        public ActionResult Join(GroupGuestModel ggm, BrowseHistory bh)
        {
            string approxtime = string.Empty;

            ViewBag.ValidateAddress = string.Empty;
            ViewBag.gid             = ggm.GroupId;
            ViewBag.lname           = ggm.LableName;
            List <BizInfo> lb = new List <BizInfo>();

            if (string.IsNullOrEmpty(ggm.GroupId) || string.IsNullOrEmpty(ggm.LableName))
            {
                ViewBag.ValidateAddress = "Oops, feel like something wrong with your input. Please check it and try again.";
            }
            else if (GroupCart.GroupCarts.ContainsKey(ggm.GroupId) == false)
            {
                ViewBag.ValidateAddress = "Oops, Group ID is not correct. Please check it and try again.";
            }
            else
            {
                List <BizInfo> lbi = BizInfoRepository.GetBizInfoByZip(GroupCart.GroupCarts[ggm.GroupId].PartyZip, true);
                foreach (var b in lbi)
                {
                    decimal st = SearchFilter.GetDistance(GroupCart.GroupCarts[ggm.GroupId].PartyAddress, b.BizAddressString, out approxtime);
                    if (st >= 0 && st <= b.DeliveryRadius && b.Delivery)
                    {
                        lb.Add(b);
                    }
                }
                ViewBag.ValidateAddress = ggm.LableName + ", to join the group ordering, select a restaurant to start.";
            }
            return(PartialView(lb));
        }
        public ActionResult DiscountResult(DeliveryCheckModel dcm, BrowseHistory bh)
        {
            ViewBag.success = string.Empty;
            string[] s          = base.GetAddressCityState(dcm.Address);
            string   approxtime = string.Empty;
            string   mysAddress = dcm.Address + " " + dcm.ZipCode;

            ViewBag.ValidateAddress = "Oops, feel like something wrong with you input. Please check it and try again.";
            if (!(string.IsNullOrEmpty(dcm.Address) || string.IsNullOrEmpty(dcm.ZipCode) || dcm.ZipCode.Length != 5 || string.IsNullOrEmpty(s[0]) || string.IsNullOrEmpty(s[1]) || string.IsNullOrEmpty(s[2])))
            {
                decimal st = SearchFilter.GetDistance(mysAddress, "1291 Parkside Dr.,Walnut Creek, CA 94596", out approxtime);
                string  xx = approxtime;
                if (st >= 0.0m)
                {
                    ViewBag.success         = "ok";
                    ViewBag.ValidateAddress = "";
                    bh.Address          = s[0];
                    bh.City             = s[1];
                    bh.State            = s[2];
                    bh.Zip              = dcm.ZipCode;
                    bh.AddressCityState = dcm.Address;
                    string goList = Url.Action("DiscountList", "Restaurants", new { vCity = s[1], vZip = dcm.ZipCode });
                    ViewBag.goList = goList;
                }
            }
            return(PartialView(dcm));
        }
        public ActionResult CheckDeliveryOKResult(DeliveryCheckModel dcm)
        {
            BizInfo bi         = BizInfoRepository.GetBizInfoById(dcm.BizInfoId);
            string  approxtime = string.Empty;
            string  mysAddress = dcm.Address + ", " + dcm.ZipCode;

            ViewBag.ValidateAddress = "Oops, feel like something wrong with you input. Please check it and try again.";
            if (string.IsNullOrEmpty(dcm.Address) || string.IsNullOrEmpty(dcm.ZipCode) || dcm.ZipCode.Length != 5)
            {
                ViewBag.ValidateAddress = "Oops, feel like something wrong with you input. Please check it and try again.";
            }
            else
            {
                decimal st = SearchFilter.GetDistance(mysAddress, bi.BizAddressString, out approxtime);
                string  xx = approxtime;
                if (st < 0.0m)
                {
                    ViewBag.ValidateAddress = "Oops, feel like something wrong with you input. Please check it and try again.";
                }
                else if (st > bi.DeliveryRadius && bi.Delivery)
                {
                    ViewBag.ValidateAddress = "Sorry, your address is beyond the area this restaurant deliveries to. Try other restaurants or you may need change your location to try again.";
                }
                else
                {
                    ViewBag.ValidateAddress = "Yes, " + dcm.BizName + " delivers to your area : " + mysAddress + ".";
                }
            }
            return(PartialView(dcm));
        }
        public ActionResult ValidateAddress(string address, string zipcode, BrowseHistory bh)
        {
            string approxtime = string.Empty;

            bh.AddressCityState = address;
            bh.Zip = zipcode;
            decimal st     = SearchFilter.GetDistance(address + " " + zipcode, "1291 Parkside Dr.,Walnut Creek, CA 94596", out approxtime);
            string  xx     = approxtime;
            string  result = "OK";

            if (st < 0.0m)
            {
                result = "failed";
            }
            return(Json(new { resp = result, xxx = approxtime }));
        }
Exemple #6
0
        public ActionResult GroupCheckoutConfirmation(GroupCheckoutModel gcm, ShoppingCart cart)
        {
            HandleCart(cart);
            TempData["valid"]       = "";
            ViewBag.ValidateAddress = string.Empty;
            ViewBag.ScheduleOK      = "OK";
            ViewBag.Restaurant      = string.Empty;
            ViewBag.LabelName       = string.Empty;
            gcm.GroupCheckoutCart   = GroupCart.GroupCarts[cart.CartKey];

            List <BizInfo> lb = new List <BizInfo>();

            if (ModelState.IsValid)
            {
                string mysAddress          = gcm.AddressLine + ", " + gcm.City + ", " + gcm.State + " " + gcm.ZipCode;
                Dictionary <int, string> l = new Dictionary <int, string>();
                foreach (var g in GroupCart.GroupCarts[cart.CartKey].PartyCart.Keys)
                {
                    int i = GroupCart.GroupCarts[cart.CartKey].PartyCart[g].BizId;
                    if (l.ContainsKey(i) == false)
                    {
                        l.Add(i, g);
                        BizInfo biz = BizInfoRepository.GetBizInfoById(i);
                        lb.Add(biz);
                    }
                }
                foreach (var b in l.Keys)
                {
                    BizInfo bi = BizInfoRepository.GetBizInfoById(b);
                    if (SearchFilter.IsOpenAt(bi, cart.ScheduleDate == "Tomorrow" ? 2 : 1, cart.ScheduleTime) == false)
                    {
                        ViewBag.ScheduleOK = "NO";
                        ViewBag.Restaurant = bi.BizTitle;
                        ViewBag.LabelName  = l[b];
                        break;
                    }
                    string approxtime = string.Empty;
                    if (string.IsNullOrEmpty(gcm.AddressLine) || string.IsNullOrEmpty(gcm.City) || string.IsNullOrEmpty(gcm.State) || string.IsNullOrEmpty(gcm.ZipCode))
                    {
                        ViewBag.ValidateAddress = "Oops, feel like something wrong with you address. Please check it and try again.";
                        break;
                    }
                    else
                    {
                        decimal st    = SearchFilter.GetDistance(mysAddress, bi.BizAddressString, out approxtime);
                        string  nouse = approxtime;
                        if (st < 0.0m)
                        {
                            ViewBag.ValidateAddress = "Oops, feel like something wrong with you address. Please check it and try again.";
                            break;
                        }
                        else if (st > bi.DeliveryRadius && bi.Delivery)
                        {
                            ViewBag.ValidateAddress = "Sorry, your address is beyond the area the restaurant deliveries. Please try other restaurants. ( Order person: " + l[b] + " | Order restaurant: " + bi.BizTitle + " )";
                            break;
                        }
                    }
                }
                if (string.IsNullOrEmpty(ViewBag.ValidateAddress) && ViewBag.ScheduleOK == "OK")
                {
                    base.CurrentCreditCard = new CreditCard();
                    base.CurrentCreditCard.CreditCardId     = 0; // base.CurrentCreditCard.CreditCardID=any
                    base.CurrentCreditCard.UserName         = string.IsNullOrEmpty(UserName) ? gcm.BillFirstName + " " + gcm.BillLastName : UserName;
                    base.CurrentCreditCard.CreditCardTypeId = int.Parse(gcm.CardType);
                    base.CurrentCreditCard.FirstName        = gcm.BillFirstName;
                    base.CurrentCreditCard.LastName         = gcm.BillLastName;

                    /*
                     * base.CurrentCreditCard.AddressLine = cm.BillAddressLine;
                     * base.CurrentCreditCard.AddressLine2 = "";
                     * base.CurrentCreditCard.City = cm.BillCity;
                     *
                     * base.CurrentCreditCard.State = cm.BillState;
                     * base.CurrentCreditCard.ZipCode = cm.BillZipCode;
                     * base.CurrentCreditCard.Country = "US";
                     */
                    base.CurrentCreditCard.Phone = gcm.Phone;
                    base.CurrentCreditCard.Email = gcm.Email;

                    base.CurrentCreditCard.CreditCardNumber = gcm.CardNumber;
                    base.CurrentCreditCard.ExpirationMonth  = int.Parse(gcm.ExpirationMonth);
                    base.CurrentCreditCard.ExpirationYear   = int.Parse(gcm.ExpirationYear);
                    base.CurrentCreditCard.SecurityCode     = int.Parse(gcm.SecurityCode);
                    base.CurrentCreditCard.AddedDate        = DateTime.Now;
                    base.CurrentCreditCard.AddedBy          = string.IsNullOrEmpty(UserName) ? gcm.BillFirstName + " " + gcm.BillLastName : UserName;;
                    base.CurrentCreditCard.UpdatedDate      = DateTime.Now;
                    base.CurrentCreditCard.UpdatedBy        = string.IsNullOrEmpty(UserName) ? gcm.BillFirstName + " " + gcm.BillLastName : UserName;;
                    base.CurrentCreditCard.Active           = true;

                    base.CurrentOrder            = new Order();
                    base.CurrentOrder.FirstName  = gcm.FirstName;
                    base.CurrentOrder.LastName   = gcm.LastName;
                    base.CurrentOrder.RoomNumber = gcm.RoomNumber;
                    base.CurrentOrder.Street     = gcm.AddressLine;
                    base.CurrentOrder.City       = gcm.City;
                    base.CurrentOrder.State      = gcm.State;
                    base.CurrentOrder.ZipCode    = gcm.ZipCode;

                    base.CurrentOrder.LogonName       = UserName;
                    base.CurrentOrder.IsLoggedUser    = User.Identity.IsAuthenticated;
                    base.CurrentOrder.CustomerMessage = gcm.Instructions;
                    base.CurrentOrder.IsDelivery      = gcm.GroupCheckoutCart.IsPartyDelivery;
                    base.CurrentOrder.ServiceCharge   = gcm.GroupCheckoutCart.PartyServiceCharge;
                    base.CurrentOrder.DeliveryCharge  = gcm.GroupCheckoutCart.PartyDeliveryFee();
                    base.CurrentOrder.DriverTip       = gcm.GroupCheckoutCart.PartyDriverTip();
                    base.CurrentOrder.IpAddress       = base.CurrentUserIP;
                    base.CurrentOrder.Phone           = gcm.Phone;
                    base.CurrentOrder.Email           = gcm.Email;
                    base.CurrentOrder.ScheduleDate    = gcm.GroupCheckoutCart.PartyScheduleDate;
                    base.CurrentOrder.ScheduleTime    = gcm.GroupCheckoutCart.PartyScheduleTime;
                    base.CurrentOrder.CouponChoice    = gcm.GroupCheckoutCart.PartyCouponChoice;
                    base.CurrentOrder.OrderTax        = gcm.GroupCheckoutCart.PartyTax();
                    base.CurrentOrder.SubTotal        = gcm.GroupCheckoutCart.PartySubTotal();
                    base.CurrentOrder.OrderTotal      = gcm.GroupCheckoutCart.PartyTotal();
                    base.CurrentOrder.BizInfoId       = cart.BizId;
                }
            }
            else
            {
                ViewBag.ValidateAddress = "Oops, feel like something wrong with you address. Please check it and try again.";
                TempData["valid"]       = "check input and try again.";
            }
            gcm.LBizForGoogleMap = lb;
            ViewBag.servicephone = ServicePhone;
            //ViewBag.maplink = GoogleMapLink(cm.BizInfo);
            return(PartialView(gcm));
        }