Exemplo n.º 1
0
 public ActionResult Edit([Bind(Include = "M_num,M_Name,M_Account,M_Password,M_Tel,M_Gender,M_Address")] Member member)
 {
     if (ModelState.IsValid)
     {
         db.Entry(member).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View("Edit", "_LayoutAdmin", member));
 }
Exemplo n.º 2
0
 public ActionResult Edit([Bind(Include = "CustomerID,Name,Email,Password,Phone,DOB,Adress")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(customer));
 }
Exemplo n.º 3
0
 public ActionResult Edit([Bind(Include = "PageID,Name,Alias,Content")] Page page)
 {
     if (ModelState.IsValid)
     {
         db.Entry(page).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(page));
 }
Exemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "PaymenMethodsID,Name")] PaymenMethod paymenmethod)
 {
     if (ModelState.IsValid)
     {
         db.Entry(paymenmethod).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(paymenmethod));
 }
Exemplo n.º 5
0
 public ActionResult Edit([Bind(Include = "UserName,Name,Middle_Name,Address,Phone_Number,Date")] Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         //return RedirectToAction("Index");
     }
     return(View(customer));
 }
Exemplo n.º 6
0
 public ActionResult Edit([Bind(Include = "CategoryID,Name,Description,ImageUrl,ParentID,SortOrder,IsPublished")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Exemplo n.º 7
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
 public ActionResult Edit([Bind(Include = "BrandID,ImageUrl,Name")] Brand brand)
 {
     if (ModelState.IsValid)
     {
         db.Entry(brand).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(brand));
 }
Exemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "Id,Question,Answer")] FAQ faq)
 {
     if (ModelState.IsValid)
     {
         db.Entry(faq).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(faq));
 }
Exemplo n.º 10
0
 public ActionResult Edit([Bind(Include = "NewsID,ImageUrl,Name,CreateDate,Author,Content,Hits")] News news)
 {
     if (ModelState.IsValid)
     {
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(news));
 }
Exemplo n.º 11
0
 public ActionResult Edit([Bind(Include = "Id,Name,Price,image,CategoryID")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryID = new SelectList(db.Categories, "Id", "Type", product.CategoryID);
     return(View(product));
 }
Exemplo n.º 12
0
        /// <summary>
        /// Add item to cart
        /// </summary>
        /// <param name="cartItem">item to be added in cart</param>
        /// <returns>whether the task was succesful or not</returns>
        public bool AddCartItem(CartItemModel cartItem, out HttpStatusCode status)
        {
            bool success = false;

            status = HttpStatusCode.OK;

            try
            {
                CartItem newCartItem = new CartItem();
                newCartItem.CartId   = cartItem.CartId;
                newCartItem.ItemId   = cartItem.ItemId;
                newCartItem.Quantity = cartItem.Quantity;

                using (ShoppingCartEntities context = new ShoppingCartEntities())
                {
                    //check if item already exists in cart
                    CartItem cartExists = context.CartItems
                                          .Include("Item")
                                          .Where(c => c.ItemId == newCartItem.ItemId && c.CartId == newCartItem.CartId)
                                          .FirstOrDefault();

                    if (cartExists == null)
                    {
                        //Add new item to car
                        context.CartItems.Add(newCartItem);
                        context.SaveChanges();
                        success = true;
                    }
                    else
                    {
                        if (cartExists.Quantity + newCartItem.Quantity > cartExists.Item.Quantity)
                        {
                            //HTTP 410 - Not enough quantity in stock
                            status = HttpStatusCode.Gone;
                        }
                        else
                        {
                            //Update quantity of item in cart
                            cartExists.Quantity += newCartItem.Quantity;
                            context.CartItems.Attach(cartExists);
                            context.Entry(cartExists).State = EntityState.Modified;
                            context.SaveChanges();
                            success = true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                new Logging().LogProgress(token, Common.CallerIP, ex);
            }

            return(success);
        }
Exemplo n.º 13
0
 public ActionResult Edit([Bind(Include = "Id,CustomerID,Date,Status")] Cart cart)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cart).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID = new SelectList(db.Customers, "UserName", "Name", cart.CustomerID);
     return(View(cart));
 }
Exemplo n.º 14
0
 public ActionResult Edit([Bind(Include = "O_num,M_num,O_Date,O_Name,O_Phone,O_Address,Status,Price")] Orders orders)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orders).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.M_num = new SelectList(db.Member, "M_num", "M_Name", orders.M_num);
     return(View(orders));
 }
        public ActionResult Create([Bind(Include = "ProductsID,CategoryID,BrandID,ImageUrl,Name,Description,Price,SalePrice,Detail,DateCreated,SortOrder,IsPublished")] Product product, HttpPostedFileBase uploadFile)
        {
            if (ModelState.IsValid)
            {
                if (uploadFile != null)
                {
                    string filePath = HttpContext.Server.MapPath("/Images");
                    uploadFile.SaveAs(filePath + "/" + uploadFile.FileName);
                    product.ImageUrl = "/images/" + uploadFile.FileName;
                }
                db.Entry(product).State = EntityState.Modified;
                db.Products.Add(product);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.BrandID    = new SelectList(db.Brands, "BrandID", "BrandID", product.BrandID);
            ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Name", product.CategoryID);
            return(View(product));
        }
 public ActionResult Edit([Bind(Include = "ImageID,ImageUrl,ProductID")] Image image)
 {
     if (ModelState.IsValid)
     {
         db.Entry(image).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ProductID = new SelectList(db.Products, "ProductsID", "ImageUrl", image.ProductID);
     return(View(image));
 }
Exemplo n.º 17
0
 public ActionResult Edit([Bind(Include = "Id,ProductId,CartId,Quantity")] CartItem cartitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(cartitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CartId    = new SelectList(db.Carts, "Id", "CustomerID", cartitem.CartId);
     ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", cartitem.ProductId);
     return(View(cartitem));
 }
Exemplo n.º 18
0
 public ActionResult Edit([Bind(Include = "ProductsID,CategoryID,BrandID,ImageUrl,Name,Description,Price,SalePrice,Detail,DateCreated,SortOrder,IsPublished")] Product product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandID    = new SelectList(db.Brands, "BrandID", "ImageUrl", product.BrandID);
     ViewBag.CategoryID = new SelectList(db.Categories, "CategoryID", "Description", product.CategoryID);
     return(View(product));
 }
Exemplo n.º 19
0
 public ActionResult Edit([Bind(Include = "OrtherID,ProductID,Name,Price,Quantily")] OrderItem orderitem)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orderitem).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.OrtherID  = new SelectList(db.Orthers, "OrtherID", "ShippingMethod", orderitem.OrtherID);
     ViewBag.ProductID = new SelectList(db.Products, "ProductsID", "ImageUrl", orderitem.ProductID);
     return(View(orderitem));
 }
Exemplo n.º 20
0
 public ActionResult Edit([Bind(Include = "OrtherID,CustomerID,DateOrdered,DateRicived,ShippingMethod,PaymentMethod,PaymentType,Status,Amout")] Orther orther)
 {
     if (ModelState.IsValid)
     {
         db.Entry(orther).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CustomerID    = new SelectList(db.Customers, "CustomerID", "Name", orther.CustomerID);
     ViewBag.PaymentMethod = new SelectList(db.PaymenMethods, "PaymenMethodsID", "Name", orther.PaymentMethod);
     return(View(orther));
 }
 public ActionResult Edit([Bind(Include = "BrandID,ProductsID,Note")] Band_Product band_product)
 {
     if (ModelState.IsValid)
     {
         db.Entry(band_product).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.BrandID    = new SelectList(db.Brands, "BrandID", "ImageUrl", band_product.BrandID);
     ViewBag.ProductsID = new SelectList(db.Products, "ProductsID", "ImageUrl", band_product.ProductsID);
     return(View(band_product));
 }
Exemplo n.º 22
0
        public ActionResult Edit([Bind(Include = "P_num,P_Name,P_Price,P_Description,P_Dimension,P_Image,P_HasMultipleStyle,PActivity_num,PClassify_num")] Product product, HttpPostedFileBase P_Image)
        {
            var    fileName = Path.GetFileName(P_Image.FileName);
            string path     = System.IO.Path.Combine(Server.MapPath("~/ProductImg/"), fileName);

            P_Image.SaveAs(path);
            if (ModelState.IsValid)
            {
                product.P_Image         = path;
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.PActivity_num = new SelectList(db.ProductActivity, "PActivity_num", "PActivity_Name", product.PActivity_num);
            ViewBag.PClassify_num = new SelectList(db.ProductClassify, "PC_num", "PC_Name", product.PClassify_num);
            return(View("Edit", "_LayoutAdmin", product));
        }
        public ActionResult Edit([Bind(Include = "CategoryID,Name,Description,ImageUrl,ParentID,SortOrder,IsPublished")] Category category, HttpPostedFileBase uploadFile)
        {
            if (ModelState.IsValid)
            {
                if (uploadFile != null)
                {
                    //string filePath = Path.Combine(HttpContext.Server.MapPath("/Images"), Path.GetFileName(uploadFile.FileName));
                    string filePath = HttpContext.Server.MapPath("/Images");
                    uploadFile.SaveAs(filePath + "/" + uploadFile.FileName);
                    category.ImageUrl = "/images/" + uploadFile.FileName;
                }
                db.Entry(category).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(category));
        }
        public ActionResult Edit([Bind(Include = "Id,ProductId,CartId,Quantity")] CartItem cartitem)
        {
            if (ModelState.IsValid)
            {
                if (cartitem.Quantity <= 0)
                {
                    @TempData["Error message"] = "Quantity is less than 0";
                }
                else if (cartitem.Quantity > 0)
                {
                    db.Entry(cartitem).State = EntityState.Modified;
                }
                db.SaveChanges();
                return(RedirectToAction("Details", "CartUser", new { id = cartitem.CartId }));
            }

            ViewBag.CartId    = new SelectList(db.Carts, "Id", "CustomerID", cartitem.CartId);
            ViewBag.ProductId = new SelectList(db.Products, "Id", "Name", cartitem.ProductId);

            return(View(cartitem));
        }
 /// <summary>
 /// 2018/12/17 Vaishnavi Soni
 /// Update an existing product category
 /// </summary>
 /// <returns>int</returns>
 public int UpdateCategory(Category categoryModel)
 {
     try
     {
         using (ShoppingCartEntities db = new ShoppingCartEntities())
         {
             var categoryToUpdate = db.Category.FirstOrDefault(em => em.CategoryId == categoryModel.CategoryId);
             if (categoryToUpdate != null)
             {
                 db.Entry(categoryToUpdate).CurrentValues.SetValues(categoryModel);
                 return(db.SaveChanges());
             }
             else
             {
                 return(-1);
             }
         }
     }
     catch (System.Exception ex)
     {
         objErrorLogger.ErrorLog(ex);
         throw ex;
     }
 }