Beispiel #1
0
        public ActionResult Order() {
            IEnumerable<t_Share_Code> scg = null;
            t_Share_Codes_Group companyInfo = null;
            t_Share_Codes_Group payInfo = null;

            if (MainInfoUser.Instance.CartItemsCount == 0) {
                return RedirectToAction("Index");
            }

            try {
                scg = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("DELIVERY_TYPE")).t_Share_Code;
            }
            catch (Exception ex) {
                Logger.Instance.Error(string.Format("Ошибка получения кодов способов доставки: {0}", ex.Message));
                return HttpNotFound();
            }

            companyInfo = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("COMPANY_INFO"));
            payInfo = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("PAY_METHOD"));

            var model = new OrderModel() {
                DeliveryPickUp = scg.FirstOrDefault(i => i.Code.Equals("DELIVERY_PICKUP")),
                DeliveryCompany = scg.FirstOrDefault(i => i.Code.Equals("DELIVERY_COMPANY"))

            };

            if (companyInfo != null) {
                model.CompanyAdress = companyInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("ADRESS")).Value;
                model.CompanyMode = companyInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("WORK_MODE")).Value;
            }

            model.PayCash = payInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("PAY_CASH"));
            model.PayCard = payInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("PAY_CARD"));

            return View(model);
        }
Beispiel #2
0
        public ActionResult GuestOrder()
        {
            IEnumerable<t_Share_Code> scg = null;
            t_Share_Codes_Group companyInfo = null;
            t_Share_Codes_Group payInfo = null;
            ViewBag.EmailDisabled = false;
            ViewBag.VisibleDeliveryAdress = false;
            if (MainInfoUser.Instance.CartItemsCount == 0)
            {
                return RedirectToAction("Index");
            }

            try
            {
                scg = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("DELIVERY_TYPE")).t_Share_Code;
            }
            catch (Exception ex)
            {
                Logger.Instance.Error(string.Format("Ошибка получения кодов способов доставки: {0}", ex.Message));
                return HttpNotFound();
            }

            companyInfo = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("COMPANY_INFO"));
            payInfo = db.ShareCodesGroupRepository.GetAll().FirstOrDefault(i => i.Code.Equals("PAY_METHOD"));

            var model = new OrderModel()
            {
                DeliveryPickUp = scg.FirstOrDefault( i => i.Code.Equals("DELIVERY_PICKUP")),
                DeliveryCompany = scg.FirstOrDefault( i => i.Code.Equals("DELIVERY_COMPANY"))
 
            };

            if (companyInfo != null)
            {
                model.CompanyAdress = companyInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("ADRESS")).Value;
                model.CompanyMode = companyInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("WORK_MODE")).Value;
            }

            model.PayCash = payInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("PAY_CASH"));
            model.PayCard = payInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("PAY_CARD"));
            model.PayOnline = payInfo.t_Share_Code.FirstOrDefault(i => i.Code.Equals("PAY_ONLINE"));
            var uc = UserContext.Current;

            if (uc.IsAuthenticated)
            {
                model.FirstName = uc.FirstName;
                model.Email = uc.Email;
                model.Phone = uc.Phone;
                ViewBag.EmailDisabled = true;
                ViewBag.BonusPoints = db.UserRepository.GetById(uc.ID).BonusPoints;
            }
            ViewBag.IsAuth = uc.IsAuthenticated;
            ViewBag.SumItem = MainInfoUser.Instance.CartItemsSum;
           
            return View(model);
        }