コード例 #1
0
 public ActionResult Edit(News news, HttpPostedFileBase image)
 {
     news.Modified    = DateTime.Now;
     news.ModifieddBy = Notice.SystemAddmin;
     if (ModelState.IsValid)
     {
         string fullPath = "~/NewsImage/" + news.Id.ToString() + news.Image;
         if (System.IO.File.Exists(fullPath))
         {
             System.IO.File.Delete(fullPath);
         }
         if (image != null && image.ContentLength > 0)
         {
             var fileName = Path.GetFileName(image.FileName);
             news.Image = fileName;
             if (fileName != null)
             {
                 image.SaveAs(Server.MapPath(Url.Content("~/NewsImage/" + news.Id.ToString() + news.Image)));
             }
         }
         db.Entry(news).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(news));
 }
コード例 #2
0
 public ActionResult Edit(FeedBacks feedBacks)
 {
     if (ModelState.IsValid)
     {
         db.Entry(feedBacks).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction(Notice.Index));
     }
     return(View(feedBacks));
 }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "RoleId,RoleName")] UserRole userRole)
 {
     if (ModelState.IsValid)
     {
         db.Entry(userRole).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(userRole));
 }
コード例 #4
0
 public ActionResult Edit([Bind(Include = "Id,Name,Phone,Email")] Register register)
 {
     if (ModelState.IsValid)
     {
         db.Entry(register).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(register));
 }
コード例 #5
0
ファイル: UsersController.cs プロジェクト: HUNGHV2/MVC_SHOP
 public ActionResult Edit(User user)
 {
     if (ModelState.IsValid)
     {
         db.Entry(user).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.RoleId = new SelectList(db.UserRoles, "RoleId", "RoleName", user.RoleId);
     return(View(user));
 }
コード例 #6
0
 public ActionResult Edit(Categories categories)
 {
     categories.ModifieddBy = Notice.SystemAddmin;
     categories.Modified    = DateTime.Now;
     if (ModelState.IsValid)
     {
         db.Entry(categories).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(categories));
 }
コード例 #7
0
 public ActionResult EditRequest(Request request)
 {
     if (ModelState.IsValid && Request.Cookies["user"] != null)
     {
         Request r = learn.Requests.Find(request.Id);
         if (request.Title != null)
         {
             r.Title = request.Title;
         }
         if (request.Describtion != null)
         {
             r.Describtion = request.Describtion;
         }
         if (request.Cost != 0)
         {
             r.Cost = request.Cost;
         }
         learn.Entry(r).State = EntityState.Modified;
         learn.SaveChanges();
         return(RedirectToAction("Requests"));
     }
     return(View("Requests"));
 }