Ejemplo n.º 1
0
        //public HttpPostedFileBase fImage { get; set; }
        public ActionResult Create(tProduct x)
        {
            payMethod pm = new payMethod();

            pm.pm(x);
            if (x.fImage != null)
            {
                string name = Guid.NewGuid().ToString() + Path.GetExtension(x.fImage.FileName);
                var    path = Path.Combine(Server.MapPath("~/Content"), name);
                x.fImage.SaveAs(path);
                x.fProductImage = "/Content/" + name;
            }
            db.tProduct.Add(x);
            db.SaveChanges();
            return(RedirectToAction("productList"));
        }
Ejemplo n.º 2
0
        public ActionResult Edit(tProduct c)
        {
            payMethod pm = new payMethod();

            if (c == null)
            {
                return(RedirectToAction("productList"));
            }
            ;
            tProduct t = db.tProduct.FirstOrDefault(z => z.fProductId == c.fProductId);

            if (t != null)
            {
                pm.pm(c);
                t.fPayByArrive     = c.fPayByArrive;
                t.fPayByCard       = c.fPayByCard;
                t.fPayByJKO        = c.fPayByJKO;
                t.fPayByLinePay    = c.fPayByLinePay;
                t.fDelivery        = c.fDelivery;
                t.fInstallment     = c.fInstallment;
                t.fInstallmentRate = c.fInstallmentRate;
                t.fProductBrand    = c.fProductBrand;
                t.fProductName     = c.fProductName;
                t.fProductPrice    = c.fProductPrice;
                t.fStock           = c.fStock;
                if (c.fImage != null)
                {
                    string name = Guid.NewGuid().ToString() + Path.GetExtension(c.fImage.FileName);
                    var    path = Path.Combine(Server.MapPath("~/Content"), name);
                    c.fImage.SaveAs(path);
                    t.fProductImage = "/Content/" + name;
                }
                db.SaveChanges();
            }
            return(RedirectToAction("productList"));
        }