Esempio n. 1
0
        public ActionResult EditProduct([Bind(Include = "ProductID,SellerUsername,ProductName,Description,Price,StockQty,CategoryID")] Product product, HttpPostedFileBase file)
        {
            string prevImageLink = new ProductsBL().GetProductByID(product.ProductID).ImageLink;
            string filename      = "";

            if (file != null && file.ContentLength > 0)
            {
                string absolutePathOfImagesFolder = Server.MapPath("\\Images");
                filename = Guid.NewGuid().ToString() + System.IO.Path.GetExtension(file.FileName);
                file.SaveAs(absolutePathOfImagesFolder + "\\" + filename);
                product.ImageLink = ("\\Images\\" + filename).ToString();
            }
            else
            {
                product.ImageLink = prevImageLink;
            }
            product.SellerUsername = User.Identity.Name;
            if (ModelState.IsValid)
            {
                db.Entry(product).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.CategoryID = new SelectList(db.ProductCategories, "CategoryID", "Name", product.CategoryID);
            ViewBag.Username   = new SelectList(db.Users, "Username", "Password", product.SellerUsername);
            return(View(product));
        }
Esempio n. 2
0
 //register
 public void AddUser(User myNewUser)
 {
     using (TradersMarketPlaceEntities tm = new TradersMarketPlaceEntities())
     {
         tm.Users.Add(myNewUser);
         tm.SaveChanges();
     }
 }
Esempio n. 3
0
 public void AddOrderDetails(OrderDetail od)
 {
     using (TradersMarketPlaceEntities tm = new TradersMarketPlaceEntities())
     {
         tm.OrderDetails.Add(od);
         tm.SaveChanges();
     }
 }
Esempio n. 4
0
 public void AddOrder(Order o)
 {
     using (TradersMarketPlaceEntities tm = new TradersMarketPlaceEntities())
     {
         tm.Orders.Add(o);
         tm.SaveChanges();
     }
 }
Esempio n. 5
0
 public ActionResult EditUser([Bind(Include = "Username,Password,Name,Surname,Email,Residence,Street,Town,Country,RoleID")] User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(user));
 }
        public ActionResult EditDetails([Bind(Include = "ProductID,ProductName,ProductQuantity,ProductPrice")] CartView cart)
        {
            Cart c = db.Carts.Find(HttpContext.User.Identity.Name, cart.ProductID);

            c.Quantity = cart.ProductQuantity;

            if (ModelState.IsValid)
            {
                db.Entry(c).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("ViewCart"));
            }
            return(View(c));
        }