public ActionResult Create(Promotions promotions)
        {
            if (ModelState.IsValid)
            {
                db.Promotion.Add(promotions);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(promotions);
        }
        public void When_promotion_applies()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new AdditionalItemDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);
            
            var actual = sut.PromotionApplies(lineItem);

            Assert.That(actual, Is.True);
        }
예제 #3
0
        public void When_no_promotion_applies()
        {
            var rule = new Mock<IPromotionalDiscountRule>();
            rule.Setup(p => p.PromotionApplies(It.IsAny<LineItem>())).Returns(false);
            var sut = new Promotions(new List<IPromotionalDiscountRule>() { rule.Object });
            var productCatalog = new ProductCatalog();
            productCatalog.AddProduct("apple", 0.75m);
            var lineItem = new LineItem("apple", 7, productCatalog, sut);

            var actual = sut.CalculatePromotionalCost(lineItem);
            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(lineItem.SubTotal));
            Assert.That(actual.DiscountNote, Is.EqualTo(""));
        }
        public void When_promotion_does_not_apply()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddQuantityDiscount("apple", 3, 2);
            productCatalog.AddProduct("apple", 0.75m);
            productCatalog.AddProduct("banana", 1m);
            var sut = new QuantityDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("banana", 7, productCatalog, promotions);

            var actual = sut.PromotionApplies(lineItem);

            Assert.That(actual, Is.False);
        }
        public void When_calculating_rule()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddQuantityDiscount("apple", 3, 2);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new QuantityDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);

            var actual = sut.Calculate(lineItem);

            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(4.75m));
            Assert.That(actual.DiscountNote, Is.EqualTo("***Discount on apple: Buy 3 apple for $2.00, New Price $4.75, Savings $0.50"));
        }
        public void When_calculating_rule()
        {
            var productCatalog = new ProductCatalog();
            productCatalog.AddAdditionalItemDiscount("apple", 1, 1, 100);
            productCatalog.AddProduct("apple", 0.75m);
            var sut = new AdditionalItemDiscountRule(productCatalog);
            var promotions = new Promotions(new List<IPromotionalDiscountRule>() { sut });
            var lineItem = new LineItem("apple", 7, productCatalog, promotions);

            var actual = sut.Calculate(lineItem);

            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(3m));
            Assert.That(actual.DiscountNote, Is.EqualTo("***Discount on apple: Buy 1 apple get 1 at $0.00, New Price $3.00, Savings $2.25"));
        }
 private void excuteNonQuery()
 {
     logincheckDataContext lc = new logincheckDataContext();
     Promotions news_add = new Promotions();
     news_add.title = titleInput.Text;
     news_add.classifyID = classifyID;
     news_add.startDate = Convert.ToDateTime(startDate.Text);
     news_add.endDate = Convert.ToDateTime(endDate.Text);
     news_add.onShelfDate = DateTime.Now.ToUniversalTime().AddHours(8);
     news_add.picPath = path.ToString();
     news_add.content = txtNewsContent.Text;
     news_add.statusID = 1;
     news_add.companyID = "C0001";
     news_add.comment = null;
     lc.Promotions.InsertOnSubmit(news_add);
     lc.SubmitChanges();
 }
예제 #8
0
        public void When_no_promotion_applies()
        {
            var rule = new Mock <IPromotionalDiscountRule>();

            rule.Setup(p => p.PromotionApplies(It.IsAny <LineItem>())).Returns(false);
            var sut = new Promotions(new List <IPromotionalDiscountRule>()
            {
                rule.Object
            });
            var productCatalog = new ProductCatalog();

            productCatalog.AddProduct("apple", 0.75m);
            var lineItem = new LineItem("apple", 7, productCatalog, sut);

            var actual = sut.CalculatePromotionalCost(lineItem);

            Assert.That(actual.DiscountedSubTotal, Is.EqualTo(lineItem.SubTotal));
            Assert.That(actual.DiscountNote, Is.EqualTo(""));
        }
예제 #9
0
        public async Task <IActionResult> Promotions(Promotions promotions)
        {
            try
            {
                if (!await enrollmentDbService.Exists(promotions.Studies, promotions.Semester))
                {
                    return(BadRequest("Promotion not found"));
                }


                await enrollmentDbService.Promotions(promotions);

                return(StatusCode(StatusCodes.Status201Created, await enrollmentDbService.GetBy(promotions.Studies, promotions.Semester + 1)));
            }
            catch
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }
        }
예제 #10
0
        protected void dl_shop_category_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Footer)
            {
                int category_id = int.Parse(dl_shop_category.DataKeys[(int)e.Item.ItemIndex].ToString());
                int shop_id     = int.Parse(Session["shop_id"].ToString());
                // dl_product.DataSource = shop_category.get_Shop_category_products(shop_id, category_id);
                //dl_product.DataBind();
                //  UpdatePanel_product.Update();
                Bind_Dl_product(shop_category.get_Shop_category_promation(shop_id, category_id));
            }
            else
            {
                int seller_id = int.Parse(Session["id"].ToString());

                int shop_id = int.Parse((Seller.get_shop_ID(seller_id).Rows[0][0]).ToString());
                Bind_Dl_product(Promotions.get_Shop_promotions(shop_id));
            }
        }
예제 #11
0
        private void HandleEmpty()
        {
            Image image = new Image()
            {
                Path = "img/establishments/none/empty.jpg"
            };
            List <Image> images = new List <Image>();

            images.Add(image);

            if (Subscriptions.Count == 0)
            {
                Establishment establishment = new Establishment()
                {
                    Name   = "Je hebt nog geen abonnementen",
                    Images = images
                };
                Subscriptions.Add(establishment);
            }

            if (Promotions.Count == 0)
            {
                Promotion p = new Promotion()
                {
                    Name   = "Er zijn nog geen promoties toegevoegd",
                    Images = images
                };

                Promotions.Add(p);
            }

            if (Events.Count == 0)
            {
                Event e = new Event()
                {
                    Name   = "Er zijn nog geen events toegevoegd",
                    Images = images
                };

                Events.Add(e);
            }
        }
예제 #12
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int id = int.Parse(Session["id"].ToString());
                lb_name.Text = BL.Seller.getName(id);


                // or
                int shop_id = int.Parse((Seller.get_shop_ID(id).Rows[0][0]).ToString());
                Session["shop_id"] = shop_id;
                //  dl_product.DataSource = Stock.get_shop_product(shop_id);
                // dl_product.DataBind();
                Bind_Dl_product(Promotions.get_Shop_promotions(shop_id));
                dl_shop_category.DataSource = shop_category.get_shop_category(shop_id);
                dl_shop_category.DataBind();

                // DataTable d = (DataTable)dl_product.DataSource;
            }
        }
예제 #13
0
    private int PointsEarnedAboveFifty(decimal transAmount, Promotions promo)
    {
        // between $51 and $100
        const int EarnedPoints = 50;
        decimal   TransAmountRoundUp;

        TransAmountRoundUp = Math.Ceiling(transAmount);
        int qualifyAmount = 0;

        if (transAmount <= promo.CapAmount)
        {
            qualifyAmount = (int)(TransAmountRoundUp - promo.ObjectiveAmount) * promo.AwardPoints;
        }
        else
        {
            // above $100
            qualifyAmount = EarnedPoints;
        }
        return(qualifyAmount);
    }
        public ActionResult Create(PromotionsViewModel Promotions)
        {
            if (ModelState.IsValid)
            {
                Promotions promotion      = new Promotions();
                var        claimsIdentity = User.Identity as ClaimsIdentity;

                UserInfo userInfo = new UserInfo(db);

                Mapper.Map(Promotions, promotion);

                Companies company = userInfo.getLoggedCompanyId(claimsIdentity);
                promotion.Companies = company;
                db.Promotions.Add(promotion);
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }

            return(View(Promotions));
        }
        /// <summary>
        /// To Verify Promotion Details in Database
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="Description"></param>
        /// <returns>
        /// returns true if we are able to get promotion details otherwise return false
        /// </return
        public bool VerifyPromotionDetailsInDatabese(string Name, string Description, string EnrollmentType, string Targeted)
        {
            Promotions promotion = new Promotions();
            int        Etype     = 0;
            int        Ptype     = 1;
            string     inputType = EnrollmentType;

            switch (EnrollmentType)
            {
            case "None":
                Etype = (int)EnrollmentTypes.None; break;

            case "Supported":
                Etype = (int)EnrollmentTypes.Supported; break;

            case "Required":
                Etype = (int)EnrollmentTypes.Required; break;

            default:
                return(false);
            }
            switch (Targeted)
            {
            case "Targeted":
                Ptype = 1; break;

            case "NonTargeted":
                Ptype = 0; break;

            default:
                return(false);
            }

            promotion = GetPromotionDetailsFromlw_promotionTableFromDB(Name, Etype, Ptype, out string message);
            if (Name.Equals(promotion.Name) && Description.Equals(promotion.Description))
            {
                return(true);
            }
            return(false);
        }
예제 #16
0
        private void CalculateTotal()
        {
            if (Promotions.Any())
            {
                Total = 0;
                var itemUsedForPromotions = new List <string>();
                foreach (var promo in Promotions)
                {
                    if (promo.Type == PromotionType.PriceForQuantityPromotion)
                    {
                        var promoType = (PriceForQuantityPromotion)promo;
                        var item      = promoType.Item;

                        var cartItem = Items.FirstOrDefault(x => x.Item.SKU == item.SKU);
                        if (cartItem == null)
                        {
                            continue;
                        }

                        var totalQuantity = Items.Where(x => x.Item.SKU == item.SKU).Sum(x => x.Quantity);
                        var qualifiedQty  = totalQuantity % promoType.Quantity;
                        Total = qualifiedQty * promoType.Total + (totalQuantity - (qualifiedQty * promoType.Quantity)) * cartItem.Item.Price;
                        itemUsedForPromotions.Add(cartItem.Item.SKU);
                    }
                }

                //Add another promotion type here.

                var nonUsedItems = Items.Where(x => !itemUsedForPromotions.Contains(x.Item.SKU));
                foreach (var nonUsedItem in nonUsedItems)
                {
                    Total += nonUsedItem.Item.Price * nonUsedItem.Quantity;
                }
            }

            else
            {
                Total = Items.Sum(x => x.Item.Price * x.Quantity);
            }
        }
 /// <summary>
 /// Create Promotion with ExtendedAttributes
 /// </summary>
 /// <param name="promotion"></param>
 /// <returns> true if ExtendedAttributes present otherwise false </returns>
 public bool CreatePromotionWithExtendedAttributes(Promotions promotion, out string msg)
 {
     try
     {
         if (!VerifyPromotionsExists(promotion.Code, promotion.Name))
         {
             Click_OnButton(Button_CreateNewPromotion);
             Driver.GetElement(Textbox_Code).SendText(promotion.Code);
             Driver.GetElement(Textbox_Name).SendText(promotion.Name);
             if (VerifyAttributeExistsInExtendedAttributes(promotion.AttributeName))
             {
                 EnterText_ExtendedAttribute(promotion.AttributeName, promotion.ValueToSetInAttribute);
                 Click_OnButton(Button_Save);
                 if (VerifyPromotionsExists(promotion.Code, promotion.Name))
                 {
                     msg = "Promotion : " + promotion.Name + " created successfully with extended attribute";
                     return(true);
                 }
                 else
                 {
                     throw new Exception("Failed to create Promotion " + promotion.Name);
                 }
             }
             else
             {
                 throw new Exception("Extended attribute field is not present, refer the screenshot for more details.");
             }
         }
         else
         {
             msg = "Promotion already exists";
             return(true);
         }
     }
     catch
     {
         throw new Exception("Failed to create new promotion with extended attribute, refer screenshot for more info");
     }
 }
        public ActionResult Create([Bind(Include = "IdPromo,IdHotel,DateDebut,DateFin,Valeur")] Promotions promotions)
        {
            if (ModelState.IsValid)
            {
                Hotels hotels = db.Hotels.Find(promotions.IdHotel);
                try
                {
                    hotels.ajouterPromotion(db, promotions);
                }
                catch (Exception)
                {
                    ViewBag.IdHotel       = new SelectList(db.Hotels, "IdHotel", "Nom");
                    ViewBag.MessageErreur = "Impossible d'ajouter cette promotion car elle chevauche une promotion existante.";
                    return(View(promotions));
                }
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.IdHotel = new SelectList(db.Hotels, "IdHotel", "Nom", promotions.IdHotel);
            return(View(promotions));
        }
예제 #19
0
        public ActionResult Promotion(int?id)
        {
            if (id == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Promotions promotion = db.Promotions.Find(id);

            if (promotion == null)
            {
                return(RedirectToAction("Index", "Home"));
            }

            Companies company = promotion.Companies;

            ViewBag.Promotion = promotion;
            ViewBag.Company   = company;

            ModelList modelList = new ModelList();

            List <JewelryCategories>          categories   = db.JewelryCategories.ToList();
            List <JewelryCategoriesViewModel> categoriesVM = new List <JewelryCategoriesViewModel>();

            Mapper.Map(categories, categoriesVM);
            modelList.add(categoriesVM, "JewelryCategories");

            for (int i = 0; i < categoriesVM.Count; i++)
            {
                List <JewelryItemsViewModel> dataVM = new List <JewelryItemsViewModel>();
                List <JewelryItems>          data   = db.JewelryItems.Where(x => x.CompanyId == company.Id).Where(x => x.CategoryJewelryId == (i + 1)).OrderByDescending(x => x.Id).ToList();
                Mapper.Map(data, dataVM);
                modelList.add(dataVM, categoriesVM[i].Name);
            }

            return(View("Promotion", modelList));
        }
예제 #20
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Promotions.Clear();
                var promotions = new List <Promotion>()
                {
                    new Promotion()
                    {
                        Id = 1, Name = "Promoção de Verão", Title = "Promoção de Verão", ShortDescription = "Musculação mensal, qualquer dia e horário por apenas R$ 69,90…", Description = "Musculação mensal, qualquer dia e horário por apenas R$ 69,90.", UrlImage = "summerpromotion"
                    },
                    new Promotion()
                    {
                        Id = 2, Name = "Suplementação", Title = "Promoção de Suplementos", ShortDescription = "Marcas nacionais e internacionais pelo melhor preço...", Description = "Marcas nacionais e internacionais pelo melhor preço", UrlImage = "suplementpromotion"
                    },
                };
                foreach (var item in promotions)
                {
                    Promotions.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
예제 #21
0
        public CatalogNameView()
        {
            InitializeComponent();

            Promotions.SetBinding(MaxHeightProperty, new Binding("ActualHeight")
            {
                Mode      = BindingMode.OneWay,
                Source    = Catalogs,
                Converter = new LambdaConverter <double>(x => x / 2)
            });
            SizeChanged += (sender, args) => {
                CatalogNamesColumn.MaxWidth = args.NewSize.Width / 2;
            };

            Catalogs.KeyDown += (sender, args) => {
                if (args.Key == Key.Escape)
                {
                    DataGridHelper.Focus(CatalogNames);
                    args.Handled = true;
                }
            };

            ApplyStyles();
        }
예제 #22
0
        private void btnDelete_Click(object sender, RoutedEventArgs e)
        {
            //if (GlobalData.VerificationDroit("CanAddPromotions"))
            //{

            var result = MessageBox.Show("Voulez vous vraiment supprimer ?", "Message", MessageBoxButton.YesNo, MessageBoxImage.Question);

            if (result == MessageBoxResult.Yes)
            {
                if (dataGrid.SelectedItem != null)
                {
                    try
                    {
                        viewM = this.Main.DataContext as PromotionsViewModel;
                        Promotions ent = dataGrid.SelectedItem as Promotions;
                        ent.Etat = "SUPPRIMER";

                        viewM.model.SaveChanges();

                        viewM.Refresh();

                        MessageBox.Show("Opération effectuée avec succès", "Promotions", MessageBoxButton.OK, MessageBoxImage.Information);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message, "Promotions", MessageBoxButton.OK, MessageBoxImage.Warning);
                        viewM.Refresh();
                    }
                }
                else
                {
                    MessageBox.Show("Aucune ligne selectionnée dans la liste", "Promotions", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            //}
        }
예제 #23
0
        public async void GetPromotions(Guid companyId)
        {
            if (Promotions == null)
            {
                Promotions = new ObservableCollection <SharedPromotion>();
            }
            Promotions.Clear();
            HttpClient client = new HttpClient();
            string     res    = await client.GetStringAsync(new Uri("http://localhost:51070/api/Promotion?companyID=" + companyId));

            var list = JsonConvert.DeserializeObject <List <SharedPromotion> >(res);

            foreach (var item in list)
            {
                // Navigate to promotionpage
                // item.Command = new DelegateCommand<Guid>(GoToPromotionDetail);
                Promotions.Add(item);
            }
            if (list.Count > 0)
            {
                Visible = Visibility.Visible;
            }
            RaisePropertyChanged("Promotions");
        }
예제 #24
0
        private void button4_Click(object sender, EventArgs e)
        {
            if (tbNewName.Text == null || tbInitals.Text == null || cbxLoc.SelectedItem == null)
            {
                tbNewName.BackColor = Color.MistyRose;
                tbInitals.BackColor = Color.MistyRose;
                cbxLoc.BackColor    = Color.MistyRose;
            }
            else
            {
                Promotions newPromo = new Promotions()
                {
                    Name     = tbNewName.Text,
                    Initals  = tbInitals.Text,
                    Location = cbxLoc.SelectedItem.ToString()
                };

                pHelper.SavePromotionsList(newPromo);

                EditMain main = new EditMain();
                main.Show();
                this.Hide();
            }
        }
예제 #25
0
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                int dayOfWeek = 0;
                //int.TryParse(collection["DayOfWeek"].ToString(), out dayOfWeek);
                Promotions promotions = new Promotions()
                {
                    Name        = collection["Name"],
                    Description = collection["Description"],
                    DayOfWeek   = collection["DayOfWeek"],
                    TimeStart   = TimeSpan.Parse(collection["TimeStart"]),
                    TimeEnd     = TimeSpan.Parse(collection["TimeEnd"]),
                    Discount    = decimal.Parse(collection["Discount"].ToString().Replace('.', ','))
                };
                db.Promotions.Add(promotions);
                db.SaveChanges();

                var Models = collection["TransportSelect2"].Split(',');
                foreach (var model in Models)
                {
                    db.PromotionsTransportModels.Add(new PromotionsTransportModels
                    {
                        TransportModels = db.TransportModels.Find(Convert.ToInt32(model)),
                        Promotions      = promotions
                    });
                }
                db.SaveChanges();

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
        public Promotions Getpro(int id)
        {
            Promotions    dpt    = new Promotions();
            string        constr = ConfigurationManager.ConnectionStrings["hrm"].ConnectionString;
            SqlConnection con    = new SqlConnection(constr);
            string        sql    = "Select * from promotion where ID=" + id;
            SqlCommand    cmd    = new SqlCommand();

            cmd.Connection  = con;
            cmd.CommandType = System.Data.CommandType.Text;
            cmd.CommandText = sql;
            con.Open();
            SqlDataReader reader = cmd.ExecuteReader();

            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    dpt.empid    = Int32.Parse(reader["ID"].ToString());
                    dpt.pro_type = reader["pro_type"].ToString();
                    dpt.amount   = double.Parse(reader["amount"].ToString());

                    dpt.activedate = DateTime.Parse(reader["activedate"].ToString());
                    dpt.pro_active = DateTime.Parse(reader["pro_active"].ToString());

                    dpt.Basic        = double.Parse(reader["Basics"].ToString());
                    dpt.HouseRent    = double.Parse(reader["HouseRent"].ToString());
                    dpt.Medicalmoney = double.Parse(reader["Medicalmoney"].ToString());
                    dpt.Convences    = double.Parse(reader["Convences"].ToString());
                    dpt.taxes        = double.Parse(reader["taxes"].ToString());
                    dpt.Gross_Salary = double.Parse(reader["Gross_Salary"].ToString());
                }
            }
            cmd.Connection.Close();
            return(dpt);
        }
예제 #27
0
        /// <summary>
        /// 添加套装到购物车
        /// </summary>
        public ActionResult AddSuit()
        {
            int pmId         = WebHelper.GetQueryInt("pmId");       //套装id
            int buyCount     = WebHelper.GetQueryInt("buyCount");   //购买数量
            int scSubmitType = WorkContext.ShopConfig.SCSubmitType; //购物车的提交方式

            //当商城不允许游客使用购物车时
            if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1)
            {
                switch (scSubmitType)
                {
                case 0:
                    return(Redirect(Url.Action("login", "account", new RouteValueDictionary {
                        { "returnUrl", Url.Action("suit", "catalog", new RouteValueDictionary {
                                { "pmId", pmId }
                            }) }
                    })));

                case 1:
                    return(Redirect(Url.Action("login", "account", new RouteValueDictionary {
                        { "returnUrl", Url.Action("suit", "catalog", new RouteValueDictionary {
                                { "pmId", pmId }
                            }) }
                    })));

                case 2:
                    return(AjaxResult("nologin", "请先登录"));

                default:
                    return(Redirect(Url.Action("login", "account", new RouteValueDictionary {
                        { "returnUrl", Url.Action("suit", "catalog", new RouteValueDictionary {
                                { "pmId", pmId }
                            }) }
                    })));
                }
            }

            //购买数量不能小于1
            if (buyCount < 1)
            {
                switch (scSubmitType)
                {
                case 0:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "购买数量不能小于1"));

                case 1:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "购买数量不能小于1"));

                case 2:
                    return(AjaxResult("buycountmin", "请填写购买数量"));

                default:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "购买数量不能小于1"));
                }
            }

            //获得套装促销活动
            SuitPromotionInfo suitPromotionInfo = Promotions.GetSuitPromotionByPmIdAndTime(pmId, DateTime.Now);

            //套装促销活动不存在时
            if (suitPromotionInfo == null)
            {
                switch (scSubmitType)
                {
                case 0:
                    return(PromptView("/", "套装不存在"));

                case 1:
                    return(PromptView("/", "套装不存在"));

                case 2:
                    return(AjaxResult("nosuit", "请选择套装"));

                default:
                    return(PromptView("/", "套装不存在"));
                }
            }

            //购物车商品列表
            List <OrderProductInfo> orderProductList     = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid);
            List <OrderProductInfo> suitOrderProductList = Carts.GetSuitOrderProductList(pmId, orderProductList, false);

            if (suitOrderProductList.Count == 0)
            {
                if ((WorkContext.Uid > 0 && orderProductList.Count >= WorkContext.ShopConfig.MemberSCCount) || (WorkContext.Uid < 1 && orderProductList.Count >= WorkContext.ShopConfig.GuestSCCount))
                {
                    switch (scSubmitType)
                    {
                    case 2:
                        return(AjaxResult("full", "购物车已满"));

                    default:
                        return(PromptView(Url.Action("index", "cart"), "购物车已满,请先结账"));
                    }
                }
            }

            //扩展套装商品列表
            List <ExtSuitProductInfo> extSuitProductList = Promotions.GetExtSuitProductList(suitPromotionInfo.PmId);

            if (extSuitProductList.Count < 1)
            {
                switch (scSubmitType)
                {
                case 0:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "套装商品为空"));

                case 1:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "套装商品为空"));

                case 2:
                    return(AjaxResult("noproduct", "套装中没有商品"));

                default:
                    return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                        { "pmId", pmId }
                    }), "套装商品为空"));
                }
            }

            //套装商品id列表
            StringBuilder pidList = new StringBuilder();

            foreach (ExtSuitProductInfo extSuitProductInfo in extSuitProductList)
            {
                pidList.AppendFormat("{0},", extSuitProductInfo.Pid);
            }
            pidList.Remove(pidList.Length - 1, 1);

            //套装商品库存列表
            List <ProductStockInfo> productStockList = Products.GetProductStockList(pidList.ToString());

            foreach (ProductStockInfo item in productStockList)
            {
                if (item.Number < buyCount)
                {
                    switch (scSubmitType)
                    {
                    case 0:
                        return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                            { "pmId", pmId }
                        }), "库存不足"));

                    case 1:
                        return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                            { "pmId", pmId }
                        }), "库存不足"));

                    case 2:
                        return(AjaxResult("stockout", item.Pid.ToString()));

                    default:
                        return(PromptView(Url.Action("suit", "catalog", new RouteValueDictionary {
                            { "pmId", pmId }
                        }), "库存不足"));
                    }
                }
            }

            buyCount = suitOrderProductList.Count == 0 ? buyCount : suitOrderProductList[0].BuyCount / suitOrderProductList[0].ExtCode2 + buyCount;
            Carts.AddSuitToCart(ref orderProductList, extSuitProductList, suitPromotionInfo, buyCount, WorkContext.Sid, WorkContext.Uid, DateTime.Now);
            //将购物车中商品数量写入cookie
            Carts.SetCartProductCountCookie(Carts.SumOrderProductCount(orderProductList));

            switch (scSubmitType)
            {
            case 0:
                return(RedirectToAction("addsuccess", new RouteValueDictionary {
                    { "type", 1 }, { "id", pmId }
                }));

            case 1:
                return(RedirectToAction("index"));

            case 2:
                return(AjaxResult("success", "添加成功"));

            default:
                return(RedirectToAction("addsuccess", new RouteValueDictionary {
                    { "type", 1 }, { "id", pmId }
                }));
            }
        }
예제 #28
0
        public void BTA120_Navigator_Create_Targeted_Promotion()
        {
            MethodBase method     = MethodBase.GetCurrentMethod();
            string     methodName = method.Name;

            testCase        = new TestCase(methodName);
            listOfTestSteps = new List <TestStep>();
            testStep        = new TestStep();
            Promotions       promotions = new Promotions();
            NonAdminUserData promotion  = new NonAdminUserData(DriverContext);

            promotions.StartDate = DateHelper.GetDate("Current");
            promotions.EndDate   = DateHelper.GetDate("Future");
            string stepName = "";

            try
            {
                #region stepName 1: "Open Navigator URL";
                stepName = "Open Navigator URL";
                var navigator_LoginPage = new Navigator_LoginPage(DriverContext);
                testStep = TestStepHelper.StartTestStep(testStep);
                navigator_LoginPage.LaunchNavigatorPortal(login.Url, out string LaunchMessage); testStep.SetOutput(LaunchMessage);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 2: "Login to Navigator using User With AllRoles";
                stepName       = "Login to Navigator using User With AllRoles";
                testStep       = TestStepHelper.StartTestStep(testStep);
                login.UserName = NavigatorUsers.NonAdminUser;
                login.Password = NavigatorUsers.NavigatorPassword;
                navigator_LoginPage.Login(login, Users.AdminRole.USER.ToString(), out string stroutput); testStep.SetOutput(stroutput);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 3: "Select organization and environment on USER page";
                stepName = "Select organization and environment on USER page";
                testStep = TestStepHelper.StartTestStep(testStep);
                var navigator_UsersHomePage = new Navigator_UsersHomePage(DriverContext);
                navigator_UsersHomePage.Navigator_Users_SelectOrganizationEnvironment();
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 4: "Create Targeted Promotion";
                stepName               = "Create Targeted Promotion";
                promotions.Code        = RandomDataHelper.RandomString(3);
                promotions.Name        = promotion.PromotionName + RandomDataHelper.RandomString(5);
                promotions.Description = "Value for " + promotions.Name;
                var navigator_PromotionPage = new Navigator_PromotionsPage(DriverContext);
                testStep = TestStepHelper.StartTestStep(testStep);
                string enrollmentType = Navigator_PromotionsPage.EnrollmentTypes.Supported.ToString();
                testStep.SetOutput(navigator_PromotionPage.Create_Promotions(Navigator_PromotionsPage.PromotionTypes.Targeted.ToString(), promotions, enrollmentType));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 5: "Verify Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page";
                stepName = "Verify Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page";
                testStep = TestStepHelper.StartTestStep(testStep);
                var result = navigator_PromotionPage.VerifyPromotionisCreatedOrNot(promotions.Code);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, result, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 6:"Create Non-Targeted Promotion";
                stepName               = "Create Non-Targeted Promotion";
                testStep               = TestStepHelper.StartTestStep(testStep);
                promotions.Code        = RandomDataHelper.RandomString(3);
                promotions.Name        = "AutoPromo_" + RandomDataHelper.RandomString(5);
                promotions.Description = "Value for " + promotions.Name;
                testStep.SetOutput(navigator_PromotionPage.Create_Promotions(Navigator_PromotionsPage.PromotionTypes.NonTargeted.ToString(), promotions, enrollmentType));
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 7: "Verify Non-Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page";
                stepName = "Verify Non-Targeted Promotion on Model -> Attribute Sets -> TxnHeader -> Rules Page";
                testStep = TestStepHelper.StartTestStep(testStep);
                result   = navigator_PromotionPage.VerifyPromotionisCreatedOrNot(promotions.Code);
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, result, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                #endregion

                #region stepName 8 :"Logout from USER page";
                stepName = "Logout from USER page";
                testStep = TestStepHelper.StartTestStep(testStep);
                navigator_LoginPage.Logout();
                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, true, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                testCase.SetStatus(true);
                #endregion
                ProjectBasePage.UpdateTestcaseStatus(method.Name.ToString(), "Passed");
            }
            catch (Exception e)
            {
                ProjectBasePage.UpdateTestcaseStatus(method.Name.ToString(), "Failed");

                testStep = TestStepHelper.EndTestStep(testCase, testStep, stepName, false, DriverContext.SendScreenshotImageContent("WEB"));
                listOfTestSteps.Add(testStep);
                testCase.SetStatus(false);
                testCase.SetErrorMessage(e.Message);
                testCase.SetImageContent(DriverContext.TakeScreenshot().ToString());
                if (!OrderTest_Status.Contains("true"))
                {
                    Assert.Fail(); testCase.SetImageContent(DriverContext.TakeScreenshot().ToString());
                }
            }
            finally
            {
                testCase.SetTestCaseSteps(listOfTestSteps);
                testCase.SetEndTime(new StringHelper().GetFormattedDateTimeNow());
                listOfTestCases.Add(testCase);
            }
        }
예제 #29
0
        /// <summary>
        /// 满减商品列表
        /// </summary>
        /// <returns></returns>
        public ActionResult FullCutProductList()
        {
            //满减促销活动id
            int pmId = GetRouteInt("pmId");

            if (pmId == 0)
            {
                pmId = WebHelper.GetQueryInt("pmId");
            }
            //开始价格
            int startPrice = GetRouteInt("startPrice");

            if (startPrice == 0)
            {
                startPrice = WebHelper.GetQueryInt("startPrice");
            }
            //结束价格
            int endPrice = GetRouteInt("endPrice");

            if (endPrice == 0)
            {
                endPrice = WebHelper.GetQueryInt("endPrice");
            }
            //排序列
            int sortColumn = GetRouteInt("sortColumn");

            if (sortColumn == 0)
            {
                sortColumn = WebHelper.GetQueryInt("sortColumn");
            }
            //排序方向
            int sortDirection = GetRouteInt("sortDirection");

            if (sortDirection == 0)
            {
                sortDirection = WebHelper.GetQueryInt("sortDirection");
            }
            //当前页数
            int page = GetRouteInt("page");

            if (page == 0)
            {
                page = WebHelper.GetQueryInt("page");
            }

            //满减促销活动
            FullCutPromotionInfo fullCutPromotionInfo = Promotions.GetFullCutPromotionByPmIdAndTime(pmId, DateTime.Now);

            if (fullCutPromotionInfo == null)
            {
                return(PromptView(Url.Action("index"), "促销活动不存在"));
            }

            PageModel pageModel = new PageModel(20, page, Promotions.GetFullCutProductCount(fullCutPromotionInfo, startPrice, endPrice));

            FullCutProductListModel model = new FullCutProductListModel()
            {
                PmId             = pmId,
                StartPrice       = startPrice,
                EndPrice         = endPrice,
                SortColumn       = sortColumn,
                SortDirection    = sortDirection,
                PageModel        = pageModel,
                ProductList      = Promotions.GetFullCutProductList(pageModel.PageSize, pageModel.PageNumber, fullCutPromotionInfo, startPrice, endPrice, sortColumn, sortDirection),
                OrderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid)
            };

            return(View(model));
        }
예제 #30
0
        /// <summary>
        /// Checks is pawn can promotion
        /// </summary>
        /// <param name="color">To checks if a black or white</param>
        public void MakePromotion(Color color)
        {
            if (color is Color.Black)
            {
                if (Position.Row == 7)
                {
                    Console.WriteLine("This pawn was promote, you can promotion a new piece.");
                    Console.WriteLine("Choose any T: Tower, B: Bishop, N: Knight and Q: Queen: ");
                    string choose = Console.ReadLine().ToUpper();

                    Promotions promotion = 0;
                    if (Enum.TryParse <Promotions>(choose, out promotion))
                    {
                        Position pos = Position;
                        Board.RemovePiece(Position);
                        switch (promotion)
                        {
                        case Promotions.T:
                            Board.PutPiece(new Rook(Board, color), pos);
                            break;

                        case Promotions.B:
                            Board.PutPiece(new Bishop(Board, color), pos);
                            break;

                        case Promotions.N:
                            Board.PutPiece(new Knight(Board, color), pos);
                            break;

                        case Promotions.Q:
                            Board.PutPiece(new Queen(Board, color), pos);
                            break;
                        }
                    }
                    else
                    {
                        throw new BoardException("Invalid promotion");
                    }
                }
            }
            else if (color is Color.White)
            {
                if (Position.Row == 0)
                {
                    Console.WriteLine("This pawn was promote, you can promotion a new piece.");
                    Console.WriteLine("Choose any T: Tower, B: Bishop, N: Knight and Q: Queen: ");
                    string choose = Console.ReadLine().ToUpper();

                    Promotions promotion;
                    if (Enum.TryParse(choose, out promotion))
                    {
                        Position pos = Position;
                        Board.RemovePiece(Position);
                        StringBuilder text = new StringBuilder();
                        switch (promotion)
                        {
                        case Promotions.T:
                            Rook rook = new Rook(Board, color);
                            Board.PutPiece(rook, pos);
                            text.AppendLine(string.Concat("Promote pawn to: ", rook.GetType()));
                            text.AppendLine(string.Concat("ChessPosition: ", rook.Position.ToChessPosition(), " CanvasPosition(Column, Row): ", rook.Position.Column, ", ", rook.Position.Row));

                            break;

                        case Promotions.B:
                            Bishop bishop = new Bishop(Board, color);
                            Board.PutPiece(bishop, pos);
                            text.AppendLine(string.Concat("Promote pawn to: ", bishop.GetType()));
                            text.AppendLine(string.Concat("ChessPosition: ", bishop.Position.ToChessPosition(), " CanvasPosition(Column, Row): ", bishop.Position.Column, ", ", bishop.Position.Row));
                            break;

                        case Promotions.N:
                            Knight knight = new Knight(Board, color);
                            Board.PutPiece(knight, pos);
                            text.AppendLine(string.Concat("Promote pawn to: ", knight.GetType()));
                            text.AppendLine(string.Concat("ChessPosition: ", knight.Position.ToChessPosition(), " CanvasPosition(Column, Row): ", knight.Position.Column, ", ", knight.Position.Row));
                            break;

                        case Promotions.Q:
                            Queen queen = new Queen(Board, color);
                            Board.PutPiece(queen, pos);
                            text.AppendLine(string.Concat("Promote pawn to: ", queen.GetType()));
                            text.AppendLine(string.Concat("ChessPosition: ", queen.Position.ToChessPosition(), " CanvasPosition(Column, Row): ", queen.Position.Column, ", ", queen.Position.Row));
                            break;
                        }
                        text.AppendLine(string.Concat("Color: ", color));
                        WriteLog.ChecksLogs(text);
                    }
                    else
                    {
                        throw new BoardException("Invalid promotion");
                    }
                }
            }
        }
        // populates the booking tab
        private async void PopulateBookingTab(JObject result)
        {
            //get the ids of promotions available for that restaurant
            string[] promotionIds = Promotions.GetPromotionIDs(result);

            var dateStart    = DateTime.Now;
            var dateStartStr = dateStart.ToString("yyyy-MM-ddTHH:mm:ss");

            var dateEnd    = DateTime.Now.AddDays(7.00);
            var dateEndStr = dateEnd.ToString("yyyy-MM-ddTHH:mm:ss");

            string url = "https://api.rdbranch.com/api/ConsumerApi/v1/Restaurant/" + this.micrositename + "/AvailabilityForDateRangeV2?";

            //get the available slots for that restaurant - with the provided partySize
            JObject r = await Requests.APICallPost(url, token, dateStartStr, dateEndStr, partySize);

            var checkAvail = r["AvailableDates"].ToString();

            //if timeSlots available
            if (r != null && checkAvail.Length > 2)
            {
                AvailabilityView.IsVisible    = true;
                NoAvailabilityLabel.IsVisible = false;

                //add promotions for that timeSlot
                if (promotionIds.Length > 0)
                {
                    string        promotions_url = "https://api.rdbranch.com/api/ConsumerApi/v1/Restaurant/" + this.micrositename + "/Promotion?";
                    StringBuilder builder        = new StringBuilder();

                    builder.Append(promotions_url);
                    foreach (string id in promotionIds)
                    {
                        builder.Append("&promotionIds=" + id);
                    }

                    JArray array_promotions = await Requests.APICallGet(builder.ToString(), token);

                    promotions.Clear();
                    foreach (var pr in array_promotions)
                    {
                        var valid = pr["ValidityPeriods"].First;

                        promotions.Add(new Promotion
                        {
                            Name        = pr["Name"].ToString(),
                            Description = pr["Description"].ToString(),
                            StartTime   = valid["StartTime"].ToString(),
                            EndTime     = valid["EndTime"].ToString(),
                            StartDate   = Convert.ToDateTime(valid["StartDate"].ToString()).Date.ToString("dd/MM/yyyy"),
                            EndDate     = Convert.ToDateTime(valid["EndDate"].ToString()).Date.ToString("dd/MM/yyyy"),
                        });
                    }
                }
            }
            else
            {
                AvailabilityView.IsVisible    = false;
                NoAvailabilityLabel.IsVisible = true;
            }

            Promotions.GetAvailablePromotions(r, slotNumber);

            AvailabilityView.ItemsSource = availableTimes;
        }
예제 #32
0
 partial void InsertPromotions(Promotions instance);
예제 #33
0
        public async Task <Promotions> Save(Promotions value, PromotionsDetail[] iosd, Guid?index)
        {
            try
            {
                //get branchId
                value.BranchId = value.CreatedBy.GetBranchOfCurrentUser(this.appContext);
                var item = this.appContext.Promotions.FirstOrDefault(p => p.PromotionId == index);
                if (item != null)
                {
                    item.Note                = value.Note;
                    item.FromDate            = value.FromDate;
                    item.ToDate              = value.ToDate;
                    item.IsOff               = value.IsOff;
                    item.UpdatedBy           = value.UpdatedBy;
                    item.UpdatedDate         = value.UpdatedDate;
                    item.IsApproved          = value.IsApproved;
                    item.CreatedByApproved   = value.CreatedByApproved;
                    item.CreatedDateApproved = value.CreatedDateApproved;

                    var iodExists = await GetDetailByIOId(item.PromotionId);

                    //update deleted
                    var iodIds       = iosd.Select(p => p.PromotionDetailId);
                    var iodNotExists = iodExists.Where(p => !iodIds.Contains(p.PromotionDetailId));
                    foreach (var itemDetail in iodNotExists)
                    {
                        itemDetail.IsDeleted = true;
                    }
                    //Insert
                    foreach (var itemDetail in iosd)
                    {
                        var itemExistD = this.appContext.PromotionsDetail.FirstOrDefault(p => p.PromotionDetailId == itemDetail.PromotionDetailId);
                        if (itemExistD != null)
                        {
                            itemExistD.MaterialId      = itemDetail.MaterialId;
                            itemExistD.PriceOrigion    = itemDetail.PriceOrigion;
                            itemExistD.PercentDiscount = itemDetail.PercentDiscount;
                            itemExistD.MoneyDiscount   = itemDetail.MoneyDiscount;
                            itemExistD.TotalPrice      = itemDetail.TotalPrice;
                            itemExistD.Note            = itemDetail.Note;
                        }
                        else
                        {
                            itemDetail.PromotionId = item.PromotionId;
                            await appContext.PromotionsDetail.AddAsync(itemDetail);
                        }
                    }
                }
                else
                {
                    var result = await appContext.Promotions.AddAsync(value);

                    foreach (var itemD in iosd)
                    {
                        await appContext.PromotionsDetail.AddAsync(itemD);
                    }
                    item = result.Entity;
                }
                //
                await appContext.SaveChangesAsync();

                var itemExist = this.appContext.Users.FirstOrDefault(p => p.Id == item.UpdatedBy.ToString());
                item.UpdatedByName = itemExist != null ? itemExist.FullName : string.Empty;
                return(item);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #34
0
 public void AddPromotion(Promotion promo)
 {
     Promotions.Add(promo);
     CalculateTotal();
 }
예제 #35
0
 public void AddPromotions(List <Promotion> promos)
 {
     Promotions.AddRange(promos);
     CalculateTotal();
 }
예제 #36
0
	private void attach_Promotions(Promotions entity)
	{
		this.SendPropertyChanging();
		entity.Company = this;
	}
예제 #37
0
        /// <summary>
        /// 商品
        /// </summary>
        public ActionResult Product()
        {
            //商品id
            int pid = GetRouteInt("pid");

            if (pid == 0)
            {
                pid = WebHelper.GetQueryInt("pid");
            }

            //判断商品是否存在
            ProductInfo productInfo = Products.GetProductById(pid);

            if (productInfo == null)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //店铺信息
            StoreInfo storeInfo = Stores.GetStoreById(productInfo.StoreId);

            if (storeInfo.State != (int)StoreState.Open)
            {
                return(PromptView("/", "你访问的商品不存在"));
            }

            //商品存在时
            ProductModel model = new ProductModel();

            //商品id
            model.Pid = pid;
            //商品信息
            model.ProductInfo = productInfo;
            //商品分类
            model.CategoryInfo = Categories.GetCategoryById(productInfo.CateId);
            //商品品牌
            model.BrandInfo = Brands.GetBrandById(productInfo.BrandId);
            //店铺信息
            model.StoreInfo = storeInfo;
            //店长信息
            model.StoreKeeperInfo = Stores.GetStoreKeeperById(storeInfo.StoreId);
            //店铺区域
            model.StoreRegion = Regions.GetRegionById(storeInfo.RegionId);
            //店铺等级信息
            model.StoreRankInfo = StoreRanks.GetStoreRankById(storeInfo.StoreRid);
            //商品图片列表
            model.ProductImageList = Products.GetProductImageList(pid);
            //扩展商品属性列表
            model.ExtProductAttributeList = Products.GetExtProductAttributeList(pid);
            //商品SKU列表
            model.ProductSKUList = Products.GetProductSKUListBySKUGid(productInfo.SKUGid);
            //商品库存数量
            model.StockNumber = Products.GetProductStockNumberByPid(pid);


            //单品促销
            model.SinglePromotionInfo = Promotions.GetSinglePromotionByPidAndTime(pid, DateTime.Now);
            //买送促销活动列表
            model.BuySendPromotionList = Promotions.GetBuySendPromotionList(productInfo.StoreId, pid, DateTime.Now);
            //赠品促销活动
            model.GiftPromotionInfo = Promotions.GetGiftPromotionByPidAndTime(pid, DateTime.Now);
            //赠品列表
            if (model.GiftPromotionInfo != null)
            {
                model.ExtGiftList = Promotions.GetExtGiftList(model.GiftPromotionInfo.PmId);
            }
            //套装商品列表
            model.SuitProductList = Promotions.GetProductAllSuitPromotion(pid, DateTime.Now);
            //满赠促销活动
            model.FullSendPromotionInfo = Promotions.GetFullSendPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);
            //满减促销活动
            model.FullCutPromotionInfo = Promotions.GetFullCutPromotionByStoreIdAndPidAndTime(productInfo.StoreId, pid, DateTime.Now);

            //广告语
            model.Slogan = model.SinglePromotionInfo == null ? "" : model.SinglePromotionInfo.Slogan;
            //商品促销信息
            model.PromotionMsg = Promotions.GeneratePromotionMsg(model.SinglePromotionInfo, model.BuySendPromotionList, model.FullSendPromotionInfo, model.FullCutPromotionInfo);
            //商品折扣价格
            model.DiscountPrice = Promotions.ComputeDiscountPrice(model.ProductInfo.ShopPrice, model.SinglePromotionInfo);

            //关联商品列表
            model.RelateProductList = Products.GetRelateProductList(pid);

            //用户浏览历史
            model.UserBrowseHistory = BrowseHistories.GetUserBrowseHistory(WorkContext.Uid, pid);

            //商品咨询类型列表
            model.ProductConsultTypeList = ProductConsults.GetProductConsultTypeList();

            //更新浏览历史
            if (WorkContext.Uid > 0)
            {
                Asyn.UpdateBrowseHistory(WorkContext.Uid, pid);
            }
            //更新商品统计
            Asyn.UpdateProductStat(pid, WorkContext.RegionId);

            return(View(model));
        }
예제 #38
0
	private void detach_Promotions(Promotions entity)
	{
		this.SendPropertyChanging();
		entity.Company = null;
	}
예제 #39
0
 partial void DeletePromotions(Promotions instance);
예제 #40
0
 partial void UpdatePromotions(Promotions instance);
예제 #41
0
        /// <summary>
        /// 直接购买套装
        /// </summary>
        /// <returns></returns>
        public ActionResult DirectBuySuit()
        {
            int pmId     = WebHelper.GetQueryInt("pmId");     //套装id
            int buyCount = WebHelper.GetQueryInt("buyCount"); //购买数量

            //当商城不允许游客使用购物车时
            if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1)
            {
                return(AjaxResult("nologin", "请先登录"));
            }

            //购买数量不能小于1
            if (buyCount < 1)
            {
                return(AjaxResult("buycountmin", "请填写购买数量"));
            }

            //获得套装促销活动
            SuitPromotionInfo suitPromotionInfo = Promotions.GetSuitPromotionByPmIdAndTime(pmId, DateTime.Now);

            //套装促销活动不存在时
            if (suitPromotionInfo == null)
            {
                return(AjaxResult("nosuit", "请选择套装"));
            }

            //购物车商品列表
            List <OrderProductInfo> orderProductList     = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid);
            List <OrderProductInfo> suitOrderProductList = Carts.GetSuitOrderProductList(pmId, orderProductList, false);

            if (suitOrderProductList.Count == 0)
            {
                if ((WorkContext.Uid > 0 && orderProductList.Count >= WorkContext.ShopConfig.MemberSCCount) || (WorkContext.Uid < 1 && orderProductList.Count >= WorkContext.ShopConfig.GuestSCCount))
                {
                    return(AjaxResult("full", "购物车已满"));
                }
            }

            //扩展套装商品列表
            List <ExtSuitProductInfo> extSuitProductList = Promotions.GetExtSuitProductList(suitPromotionInfo.PmId);

            if (extSuitProductList.Count < 1)
            {
                return(AjaxResult("noproduct", "套装中没有商品"));
            }

            //套装商品id列表
            StringBuilder pidList = new StringBuilder();

            foreach (ExtSuitProductInfo extSuitProductInfo in extSuitProductList)
            {
                pidList.AppendFormat("{0},", extSuitProductInfo.Pid);
            }
            pidList.Remove(pidList.Length - 1, 1);

            //套装商品库存列表
            List <ProductStockInfo> productStockList = Products.GetProductStockList(pidList.ToString());

            foreach (ProductStockInfo item in productStockList)
            {
                if (item.Number < buyCount)
                {
                    return(AjaxResult("stockout", item.Pid.ToString()));
                }
            }

            buyCount = suitOrderProductList.Count == 0 ? buyCount : suitOrderProductList[0].BuyCount / suitOrderProductList[0].ExtCode3 + buyCount;
            Carts.AddSuitToCart(ref orderProductList, extSuitProductList, suitPromotionInfo, buyCount, WorkContext.Sid, WorkContext.Uid, DateTime.Now);
            //将购物车中商品数量写入cookie
            Carts.SetCartProductCountCookie(Carts.SumOrderProductCount(orderProductList));

            return(AjaxResult("success", Url.Action("confirmorder", "order", new RouteValueDictionary {
                { "selectedCartItemKeyList", "1_" + pmId }
            })));
        }
 public ActionResult Edit(Promotions promotions)
 {
     if (ModelState.IsValid)
     {
         db.Entry(promotions).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(promotions);
 }
예제 #43
0
        /// <summary>
        /// 添加满赠到购物车
        /// </summary>
        public ActionResult AddFullSend()
        {
            //当商城不允许游客使用购物车时
            if (WorkContext.ShopConfig.IsGuestSC == 0 && WorkContext.Uid < 1)
            {
                return(AjaxResult("nologin", "请先登录"));
            }

            int    pmId = WebHelper.GetQueryInt("pmId");                                          //满赠id
            int    pid  = WebHelper.GetQueryInt("pid");                                           //商品id
            string selectedCartItemKeyList = WebHelper.GetQueryString("selectedCartItemKeyList"); //选中的购物车项键列表

            //添加的商品
            PartProductInfo partProductInfo = Products.GetPartProductById(pid);

            if (partProductInfo == null)
            {
                return(AjaxResult("noproduct", "请选择商品"));
            }

            //商品库存
            int stockNumber = Products.GetProductStockNumberByPid(pid);

            if (stockNumber < 1)
            {
                return(AjaxResult("stockout", "商品库存不足"));
            }

            //满赠促销活动
            FullSendPromotionInfo fullSendPromotionInfo = Promotions.GetFullSendPromotionByPmIdAndTime(pmId, DateTime.Now);

            if (partProductInfo == null)
            {
                return(AjaxResult("nopromotion", "满赠促销活动不存在或已经结束"));
            }

            //购物车商品列表
            List <OrderProductInfo> orderProductList = Carts.GetCartProductList(WorkContext.Uid, WorkContext.Sid);

            //满赠主商品列表
            List <OrderProductInfo> fullSendMainOrderProductList = Carts.GetFullSendMainOrderProductList(pmId, orderProductList);

            if (fullSendMainOrderProductList.Count < 1)
            {
                return(AjaxResult("nolimit", "不符合活动条件"));
            }
            decimal amount = Carts.SumOrderProductAmount(fullSendMainOrderProductList);

            if (fullSendPromotionInfo.LimitMoney > amount)
            {
                return(AjaxResult("nolimit", "不符合活动条件"));
            }

            if (!Promotions.IsExistFullSendProduct(pmId, pid, 1))
            {
                return(AjaxResult("nofullsendproduct", "此商品不是满赠商品"));
            }

            //赠送商品
            OrderProductInfo fullSendMinorOrderProductInfo = Carts.GetFullSendMinorOrderProduct(pmId, orderProductList);

            if (fullSendMinorOrderProductInfo != null)
            {
                if (fullSendMinorOrderProductInfo.Pid != pid)
                {
                    Carts.DeleteCartFullSend(ref orderProductList, fullSendMinorOrderProductInfo);
                }
                else
                {
                    return(AjaxResult("exist", "此商品已经添加"));
                }
            }

            //添加满赠商品
            Carts.AddFullSendToCart(ref orderProductList, partProductInfo, fullSendPromotionInfo, WorkContext.Sid, WorkContext.Uid, DateTime.Now);

            //商品数量
            int pCount = Carts.SumOrderProductCount(orderProductList);
            //选中的订单商品列表
            List <OrderProductInfo> selectedOrderProductList = null;
            //购物车项列表
            List <CartItemInfo> cartItemList = Carts.TidyOrderProductList(StringHelper.SplitString(selectedCartItemKeyList), orderProductList, out selectedOrderProductList);

            //商品总数量
            int totalCount = Carts.SumOrderProductCount(selectedOrderProductList);
            //商品合计
            decimal productAmount = Carts.SumOrderProductAmount(selectedOrderProductList);
            //满减折扣
            int fullCut = Carts.SumFullCut(cartItemList);
            //订单合计
            decimal orderAmount = productAmount - fullCut;

            CartModel model = new CartModel
            {
                TotalCount    = totalCount,
                ProductAmount = productAmount,
                FullCut       = fullCut,
                OrderAmount   = orderAmount,
                CartItemList  = cartItemList
            };

            //将购物车中商品数量写入cookie
            Carts.SetCartProductCountCookie(pCount);

            return(View("ajaxindex", model));
        }
예제 #44
0
	private void detach_Promotions(Promotions entity)
	{
		this.SendPropertyChanging();
		entity.Classfication = null;
	}