public ActionResult Apply(int id, DiscountModel discount)
        {
            Article article = db.Articles.Find(id);

            if (article == null)
            {
                return(HttpNotFound());
            }

            if (article.OriginalPrice != null)
            {
                article.Price = article.OriginalPrice.Value;
            }

            article.OriginalPrice       = article.Price;
            article.DiscountDescription = discount.Description;
            if (discount.Type == 1)
            {
                article.Price = (article.Price * (100 - discount.Value)) / 100;
            }
            else if (discount.Type == 2)
            {
                article.Price = article.Price - discount.Value;
            }

            article.DiscountDescription = discount.Description;

            db.SaveChanges();

            return(RedirectToAction("Index", "Articles"));
        }
        public ActionResult Create(int articleId, int categoryId)
        {
            if (ModelState.IsValid)
            {
                Article  article  = db.Articles.Find(articleId);
                Category category = db.Categories.Find(categoryId);

                Category currentCategory = category;
                while (currentCategory != null)
                {
                    if (!article.Categories.Contains(currentCategory))
                    {
                        article.Categories.Add(currentCategory);
                    }

                    currentCategory = currentCategory.ParentCategory;
                }

                db.SaveChanges();

                return(RedirectToAction("Details", "Articles", new { id = article.Id }));
            }

            ViewBag.ArticleId  = new SelectList(db.Articles, "Id", "Title", articleId);
            ViewBag.CategoryId = new SelectList(db.Colors, "Id", "Title", categoryId);

            return(View());
        }
        public ActionResult Create([Bind(Include = "Id,Title")] SizeType sizetype)
        {
            if (ModelState.IsValid)
            {
                db.SizeTypes.Add(sizetype);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(sizetype));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "Id,Title")] Color color)
        {
            if (ModelState.IsValid)
            {
                db.Colors.Add(color);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(color));
        }
        public ActionResult Create([Bind(Include = "Id,Name,Description,ImageUrl,DateCreated")] Collection collection)
        {
            if (ModelState.IsValid)
            {
                db.Collections.Add(collection);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(collection));
        }
Example #6
0
        public ActionResult Create([Bind(Include = "Id,TypeId,Name,OrderIndex")] Size size)
        {
            if (ModelState.IsValid)
            {
                db.Sizes.Add(size);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.TypeId = new SelectList(db.SizeTypes, "Id", "Title", size.TypeId);
            return(View(size));
        }
        public ActionResult Create([Bind(Include = "ArticleId,SmallImageUrl,MediumImageUrl,LargelImageUrl,OrderIndex,Id")] ArticleImage articleimage)
        {
            if (ModelState.IsValid)
            {
                db.ArticleImages.Add(articleimage);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArticleId = new SelectList(db.Articles, "Id", "UrlName", articleimage.ArticleId);
            return(View(articleimage));
        }
Example #8
0
        public ActionResult Create([Bind(Include = "Id,DeliveryMerchant,DeliveryPrice,HasCommission,CommissionPercents,ShippingPrice,ItemsPrice,TotalPrice,UserId,StatusId,DateCreated,PaymentMethodId")] Order order)
        {
            if (ModelState.IsValid)
            {
                db.Orders.Add(order);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.StatusId = new SelectList(db.OrderStatuses, "Id", "Name", order.StatusId);
            return(View(order));
        }
Example #9
0
        public ActionResult Create([Bind(Include = "Id,UrlName,Title,ParentCategoryId,OrderIndex")] Category category)
        {
            if (ModelState.IsValid)
            {
                db.Categories.Add(category);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ParentCategoryId = new SelectList(db.Categories, "Id", "UrlName", category.ParentCategoryId);
            return(View(category));
        }
        public ActionResult Create([Bind(Include = "ArticleId,SizeId,ColorId,Quantity")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                db.Stocks.Add(stock);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ArticleId = new SelectList(db.Articles, "Id", "UrlName", stock.ArticleId);
            ViewBag.ColorId   = new SelectList(db.Colors, "Id", "Title", stock.ColorId);
            ViewBag.SizeId    = new SelectList(db.Sizes, "Id", "Name", stock.SizeId);
            return(View(stock));
        }
        public ActionResult Create([Bind(Include = "Id,UrlName,Title,DateCreated,Price,Description,ShortDescription,MaterialDescription,ThumbnailUrl,SizeTypeId,Visible,LikesCount,OrdersCount,CollectionId,IsFeatured,IsRecommended")] Article article)
        {
            if (ModelState.IsValid)
            {
                db.Articles.Add(article);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.SizeTypeId   = new SelectList(db.SizeTypes, "Id", "Title", article.SizeTypeId);
            ViewBag.CollectionId = new SelectList(db.Collections, "Id", "Name", article.CollectionId);

            return(View(article));
        }