Exemple #1
0
        public ActionResult EditProduct(ProductViewModel model, string[] photoNames, List <HttpPostedFileBase> photoPath)
        {
            /*
             */
            //update photo
            string photoName = "";
            string fullPath  = "";
            int    i         = 0;

            //i degiskeni; photoPath her zman product ın photo sayısı uzunlugunda gelir.Ama photoNAmes güncelleneck olan photo sayısı kadar gelecegi icin  i degiskeni kullanıldı.
            for (int k = 0; k < photoPath.Count(); k++)
            {
                if (photoPath[k] != null)
                {
                    photoName = Guid.NewGuid().ToString().Replace("-", "") + ".jpg";
                    string path = Server.MapPath("~/Upload/Product/" + photoName);
                    photoPath[k].SaveAs(path);
                    pr.PhotoUpdate(photoNames[i], model.Product.ProductID, photoName);
                    fullPath = Request.MapPath("~/Upload/Product/" + photoNames[i]);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    i++;
                }
            }
            pr.Update(model.Product);
            return(RedirectToAction("List"));
        }
        public ActionResult Pay(Invoice model, List <string> PaymentTypes)
        {
            model.PaymentDate = DateTime.Now;
            foreach (string item in PaymentTypes)
            {
                int PaymentId = Convert.ToInt32(item);
                model.PaymentTypeId = PaymentId;
            }
            model.OrderId = ((Order)Session["Order"]).OrderId;
            InvoiceRep ip = new InvoiceRep();

            if (ip.Insert(model).IsSuccessed)
            {
                List <Product> proList   = new List <Product>();
                Order          ord       = (Order)Session["Order"];
                OrderRep       ordrep    = new OrderRep();
                OrderDetailRep ordDetRep = new OrderDetailRep();
                ProductRep     proRep    = new ProductRep();
                Result <List <OrderDetail> > ordDetRes = ordDetRep.GetListByOrdId((int)model.OrderId);
                foreach (OrderDetail item in ordDetRes.ProcessResult)
                {
                    Product pr = proRep.GetObjById(item.ProductId).ProcessResult;
                    if (pr.Stock != null)
                    {
                        if (pr.Stock < item.Quantity)
                        {
                            string msg = "Yeterli sayida stok yok";
                            return(RedirectToAction("DetailList", "Order", new { msg = msg }));
                        }
                        else
                        {
                            pr.Stock -= item.Quantity;
                            proList.Add(pr);
                        }
                    }
                }
                Member mem = (Member)Session["UserID"];
                if (mem != null)
                {
                    ord.MemberId = mem.UserId;
                    ord.IsPay    = true;
                    ordrep.Update(ord);
                    foreach (Product item in proList)
                    {
                        proRep.Update(item);
                    }
                    Session["Order"] = null;
                    return(RedirectToAction("LatestOrders", "Home"));
                }
                else
                {
                    return(RedirectToAction("SignIn", "Home"));
                }
            }
            else
            {
                return(View(model));
            }
        }
Exemple #3
0
        public ActionResult Edit(ProductViewModel model, HttpPostedFileBase photo)
        {
            string photoName = model.Product.Photo;

            if (photo != null)
            {
                if (photo.ContentLength > 0)
                {
                    string ext = Path.GetExtension(photo.FileName);
                    photoName = Guid.NewGuid().ToString().Replace("-", "");
                    if (ext == ".jpg")
                    {
                        photoName += ext;
                    }
                    else if (ext == ".png")
                    {
                        photoName += ext;
                    }
                    else if (ext == ".bmp")
                    {
                        photoName += ext;
                    }
                    else
                    {
                        ViewBag.Mesaj = "Lütfen .jpg,.png,.bmp tipinde resim yukleyiniz";
                        return(View(model));
                    }
                    string path = Server.MapPath("~/Upload/" + photoName);
                    photo.SaveAs(path);
                }
            }
            model.Product.Photo = photoName;
            result.resultint    = pr.Update(model.Product);
            if (result.resultint.ProcessResult > 0)
            {
                return(RedirectToAction("List"));
            }
            else
            {
                return(View(model));
            }
        }
 public object UpdateProduct(String id, ProductReq req)
 {
     //Tạo giá trị và trả về
     return(_rep.Update(id, req));
 }
Exemple #5
0
 public object UpdateProduct(String id, ProductReq req)
 {
     return(productRep.Update(id, req));
 }