Exemple #1
0
 public ActionResult Edit(Product product, HttpPostedFileBase fileUpload)
 {
     if (fileUpload != null && fileUpload.ContentLength > 0)
     {
         if (ModelState.IsValid)
         {
             if (fileUpload != null && fileUpload.ContentLength > 0)
             {
                 List <FileUploadModel> uploadFileModel = new List <FileUploadModel>();
                 string fileName = Path.GetFileName(fileUpload.FileName);
                 var    path     = Path.Combine(Server.MapPath(Constants.PATH_IMAGE), fileName);
                 if (!System.IO.File.Exists(path))
                 {
                     Bitmap resizedImage = ParamHelper.Instance.ResizeImage(
                         Bitmap.FromStream(fileUpload.InputStream), Constants.IMAGE_WIDTH, Constants.IMAGE_HEIGHT);
                     resizedImage.Save(path, System.Drawing.Imaging.ImageFormat.Png);
                 }
                 product.Image = fileName;
             }
             product.ModifiedDate    = DateTime.Now;
             db.Entry(product).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     ViewBag.ManufacturerId = new SelectList(db.Manufacturers, "Id", "Name", product.ManufacturerId);
     return(View(product));
 }
 public ActionResult Edit(Promotion promotion)
 {
     if (ModelState.IsValid)
     {
         promotion.ModifiedDate    = DateTime.Now;
         db.Entry(promotion).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(promotion));
 }
 public ActionResult Edit(Customer customer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(customer).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(customer);
 }
Exemple #4
0
 public ActionResult Edit(Manufacturer manufacturer)
 {
     if (ModelState.IsValid)
     {
         db.Entry(manufacturer).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(manufacturer));
 }
 public ActionResult Edit(Staff staff)
 {
     if (ModelState.IsValid)
     {
         db.Entry(staff).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.PositionId = new SelectList(db.Positions, "Id", "Name", staff.PositionId);
     return(View(staff));
 }
        public ActionResult ChooseDeliverer(string staffId)
        {
            string          orderId    = Session["OrderId"].ToString();
            Delivery        delivery   = new Delivery();
            List <Delivery> deliveries = db.Deliveries.ToList();
            string          oldId      = "";

            if (deliveries.Count > 0)
            {
                oldId = deliveries[deliveries.Count - 1].Id;
            }
            delivery.Id      = ParamHelper.Instance.GetNewId(oldId, Constants.PREFIX_DELIVERY);
            delivery.OrderId = orderId;
            delivery.Date    = DateTime.Now;
            delivery.StaffId = staffId;
            db.Deliveries.Add(delivery);
            db.SaveChanges();
            Order order = db.Orders.Find(orderId);

            order.IsAssigned      = true;
            db.Entry(order).State = EntityState.Modified;
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult ChooseOrders()
 {
     if (!String.IsNullOrEmpty(Request["ChooseOrders"]))
     {
         foreach (var orderId in Request["ChooseOrders"].Split(','))
         {
             Delivery delivery = db.Deliveries.Find(orderId);
             if (delivery != null)
             {
                 delivery.IsDelivered     = true;
                 db.Entry(delivery).State = EntityState.Modified;
                 db.SaveChanges();
                 return(new Rotativa.ViewAsPdf("Prints", delivery));
             }
         }
     }
     return(RedirectToAction("Index"));
 }