Esempio n. 1
0
        public ActionResult DeleteConfirmed(Guid id)
        {
            OwnerProduct ownerProduct = db.OwnerProducts.Find(id);

            db.OwnerProducts.Remove(ownerProduct);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
 public ActionResult Edit([Bind(Include = "Id,UserId,Name,Price,Quantity,Description")] OwnerProduct ownerProduct)
 {
     if (ModelState.IsValid)
     {
         db.Entry(ownerProduct).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.UserId = User.Identity.GetUserId();
     return(View(ownerProduct));
 }
Esempio n. 3
0
        public ActionResult Create([Bind(Include = "Id,UserId,Name,Price,Quantity,Description")] OwnerProduct ownerProduct)
        {
            if (ModelState.IsValid)
            {
                ownerProduct.Id = Guid.NewGuid();
                db.OwnerProducts.Add(ownerProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserId = User.Identity.GetUserId();
            return(View(ownerProduct));
        }
Esempio n. 4
0
        // GET: OwnerProducts/Details/5
        public ActionResult Details(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OwnerProduct ownerProduct = db.OwnerProducts.Find(id);

            if (ownerProduct == null)
            {
                return(HttpNotFound());
            }
            return(View(ownerProduct));
        }
Esempio n. 5
0
        public ActionResult _ProductImagesDetail(Guid id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OwnerProduct ownerProduct = db.OwnerProducts.Find(id);

            if (ownerProduct == null)
            {
                return(HttpNotFound());
            }
            return(PartialView(ownerProduct));
        }
Esempio n. 6
0
        // GET: OwnerProducts/Edit/5
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            OwnerProduct ownerProduct = db.OwnerProducts.Find(id);

            if (ownerProduct == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserId = User.Identity.GetUserId();
            return(View(ownerProduct));
        }
Esempio n. 7
0
        public OwnerProductViewModel(OwnerProduct dbModel)
        {
            this.Id          = dbModel.Id;
            this.UserId      = dbModel.UserId;
            this.Name        = dbModel.Name;
            this.Price       = dbModel.Price;
            this.Quantity    = dbModel.Quantity;
            this.Margin      = dbModel.Margin;
            this.Description = dbModel.Description;
            this.UserName    = dbModel.User.UserName;

            if (dbModel.OwnerProductImages != null && dbModel.OwnerProductImages.Count > 0)
            {
                this.ProfileImagePath = dbModel.OwnerProductImages.FirstOrDefault().Path;
            }
            else
            {
                this.ProfileImagePath = "/Imgs/diaochan.jpg";
            }
        }
Esempio n. 8
0
        public DetailOwnerProductViewModel(OwnerProduct product)
        {
            this.OwnerProductImages = new List <OwnerProductImage>();

            this.Id          = product.Id;
            this.UserId      = product.UserId;
            this.Name        = product.Name;
            this.Price       = product.Price;
            this.Quantity    = product.Quantity;
            this.Description = product.Description;
            this.User        = product.User;

            if (product.OwnerProductImages != null && product.OwnerProductImages.Count > 0)
            {
                foreach (var productImage in product.OwnerProductImages)
                {
                    this.OwnerProductImages.Add(productImage);
                }
            }
        }