Esempio n. 1
0
 public ActionResult Edit(Product p)
 {
     ViewBag.CategoryId = new SelectList(_cat.GetAll(), "CategoryId", "CategoryName", p.CategoryId);
     ViewBag.SupplierId = new SelectList(_sup.GetAll(), "SupplierId", "SupplierName", p.SupplierId);
     ViewBag.proNote    = _note.GetBy(x => x.Type == 2).AsEnumerable();
     ViewBag.AttrType   = _attr.GetAll().AsQueryable().Include(x => x.Attributes).AsEnumerable();
     if (p.ProductAttrs != null)
     {
         _prAttr.RemoveRange(_prAttr.GetBy(x => x.ProductId == p.ProductId));
         p.ProductAttrs.ToList().ForEach(x => x.ProductId = p.ProductId);
         _prAttr.AddRange(p.ProductAttrs);
     }
     if (p.ProductNotes != null)
     {
         _proNote.RemoveRange(_proNote.GetBy(x => x.ProductId == p.ProductId));
         p.ProductNotes.ToList().ForEach(x => x.ProductId = p.ProductId);
         _proNote.AddRange(p.ProductNotes);
     }
     if (ModelState.IsValid)
     {
         if (_product.Edit(p))
         {
             return(RedirectToAction("Index"));
         }
         return(View(p));
     }
     return(View(p));
 }
Esempio n. 2
0
 public ActionResult Edit(Business b)
 {
     if (ModelState.IsValid)
     {
         if (_business.Edit(b))
         {
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     return(View());
 }
 public ActionResult Edit(AttributeType atty)
 {
     if (ModelState.IsValid)
     {
         if (_atty.Edit(atty))
         {
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     return(View());
 }
 public ActionResult Edit(Note n)
 {
     if (ModelState.IsValid)
     {
         if (_note.Edit(n))
         {
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     return(View());
 }
 public ActionResult Edit(Attributes attr)
 {
     ViewBag.TypeId = new SelectList(_atty.GetAll(), "AttrTypeId", "TypeName");
     if (ModelState.IsValid)
     {
         if (_attr.Edit(attr))
         {
             return(RedirectToAction("Index"));
         }
         return(View());
     }
     return(View());
 }
 public ActionResult Edit(Supplier sup)
 {
     if (ModelState.IsValid)
     {
         if (_sup.Edit(sup))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(sup));
         }
     }
     return(View(sup));
 }
Esempio n. 7
0
 public ActionResult Edit(Post p)
 {
     if (ModelState.IsValid)
     {
         if (_pos.Edit(p))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(p));
         }
     }
     return(View(p));
 }
Esempio n. 8
0
 public ActionResult Edit(Category c)
 {
     if (ModelState.IsValid)
     {
         if (_cat.Edit(c))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(c));
         }
     }
     return(View(c));
 }
Esempio n. 9
0
 public ActionResult Edit(Banner b)
 {
     ViewBag.NoteId = new SelectList(_note.GetBy(x => x.Type == 1), "Id", "AttrName", b.NoteId);
     if (ModelState.IsValid)
     {
         if (_ban.Edit(b))
         {
             return(RedirectToAction("Index"));
         }
         else
         {
             return(View(b));
         }
     }
     return(View(b));
 }
        public ActionResult Edit(User us)
        {
            ViewBag.GroupId = new SelectList(_gr.GetAll(), "GroupId", "GroupName");

            try
            {
                if (ModelState.IsValid)
                {
                    if (_us.GetAll().Any(x => x.UserName != us.UserName))
                    {
                        if (_us.Edit(us))
                        {
                            TempData["msg"] = new ResponseMessage()
                            {
                                Type    = "alert-success",
                                Message = "Update Done!"
                            };
                            return(RedirectToAction("Index"));
                        }
                        else
                        {
                            TempData["msg"] = new ResponseMessage()
                            {
                                Type    = "alert-danger",
                                Message = "Update Fail!"
                            };
                        }
                    }


                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                TempData["msg"] = new ResponseMessage()
                {
                    Type    = "alert-danger",
                    Message = ex.Message
                };
            }
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit(User u)
 {
     _u.Edit(u);
     return(RedirectToAction("Index"));
 }