public bool Update(User entity) { try { using (var DB = new OnlineShopDbContext()) { //var user = DB.Users.FirstOrDefault(x => x.ID == entity.ID); //user.Name = entity.Name; //if (!string.IsNullOrEmpty(entity.Password)) //{ // user.Password = entity.Password; //} //user.GroupID = entity.GroupID; //user.Address = entity.Address; //user.Email = entity.Email; //user.ModifiedBy = entity.ModifiedBy; //user.ModifiedDate = DateTime.Now; //DB.SaveChanges(); //return true; DB.Entry(entity).State = EntityState.Modified; DB.SaveChanges(); return(true); } } catch (Exception ex) { //logging return(false); } }
public ActionResult Edit(ProductCategory entity) { if (ModelState.IsValid) { var user = (UserLogin)Session[CommonConstants.USER_SESSION]; entity.CreatedBy = user.Name; entity.CreatedDate = DateTime.Now; if (entity.Status == null) { entity.Status = false; } db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(entity)); }
public bool ChangeStatus(int id) { var data = db.Contents.Find(id); data.Status = !data.Status; db.Entry(data).State = EntityState.Modified; db.SaveChanges(); return(data.Status); }
public ActionResult Edit([Bind(Include = "ID,Name,Phone,Email,Address,Content,CreatedDate,Status")] FeedBack feedBack) { if (ModelState.IsValid) { db.Entry(feedBack).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feedBack)); }
public ActionResult Edit([Bind(Include = "ID,Name,Type,Value,Status")] SystemConfig systemConfig) { if (ModelState.IsValid) { db.Entry(systemConfig).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(systemConfig)); }
public ActionResult Edit([Bind(Include = "ID,Image,DisplayOrder,Link,Description,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,Status")] Slide slide) { if (ModelState.IsValid) { db.Entry(slide).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(slide)); }
public ActionResult Edit([Bind(Include = "ID,Name,MetaTitle,ParentID,DisplayOrder,SeoTitle,Status,CreatedDate,CreateBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDescriptions,ShowOnHome")] Category category) { if (ModelState.IsValid) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(category)); }
public ActionResult Edit([Bind(Include = "ID,Name")] Role role) { if (ModelState.IsValid) { db.Entry(role).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(role)); }
public ActionResult Edit([Bind(Include = "ID,Content,Status")] Footer footer) { if (ModelState.IsValid) { db.Entry(footer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(footer)); }
public ActionResult Edit([Bind(Include = "ID,Code,Name,MetaTitle,Description,Image,MoreImages,CategoryID,Detail,Wantity,CreatedDate,CreateBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDescriptions,Status,TopHot,ViewCount")] Content content) { if (ModelState.IsValid) { db.Entry(content).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(content)); }
public ActionResult Update(Customer cust) { if (ModelState.IsValid) { db.Entry(cust).State = EntityState.Modified; db.SaveChanges(); Session["username"] = cust.UserName; return(RedirectToAction("Index", "Home")); } return(View()); }
public void Edit(TinTuc tt) { try { db.Entry(tt).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); } catch (Exception) { } }
public ActionResult Edit([Bind(Include = "ContentID,TagID")] ContentTag contentTag) { if (ModelState.IsValid) { db.Entry(contentTag).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.ContentID = new SelectList(db.Contents, "ID", "Name", contentTag.ContentID); ViewBag.TagID = new SelectList(db.Tags, "ID", "Name", contentTag.TagID); return(View(contentTag)); }
public bool RemoveCredential(string userGroup, string roles) { var data = new Credential() { UserGroupID = userGroup, RoleID = roles }; //db.Credentials.Remove(); db.Entry(data).State = EntityState.Deleted; db.SaveChanges(); return(true); }
public bool Update(User user) { try { db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(true); } catch (Exception ex) { System.Console.WriteLine(ex.Message); return(false); } }
public ActionResult Edit(Slide entity, HttpPostedFileBase file) { var oldSlide = new SlideDao().ViewDetail(entity.ID); string pathOldImage = Server.MapPath("~") + entity.Image; if (System.IO.File.Exists(pathOldImage)) { System.IO.File.Delete(pathOldImage); } string path = Server.MapPath("~/assets/client/images/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } var defName = DateTime.Now.ToString("MM_dd_yyyy_HH_mm_ss"); if (file != null) { var extension = Path.GetExtension(file.FileName); string fileName = defName + "_" + Path.GetFileNameWithoutExtension(file.FileName) + extension; file.SaveAs(Path.Combine(path, fileName)); } if (ModelState.IsValid) { var user = (UserLogin)Session[CommonConstants.USER_SESSION]; entity.CreatedBy = user.Name; entity.CreatedDate = DateTime.Now; if (entity.Status == null) { entity.Status = false; } if (file != null) { var extension = Path.GetExtension(file.FileName); entity.Image = "/assets/client/images/" + defName + "_" + Path.GetFileNameWithoutExtension(file.FileName) + extension; } else { entity.Image = oldSlide.Image; } db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(entity)); }
public ActionResult Edit([Bind(Include = "ID,Name,MetaTitle,Description,Image,CategoryID,Detail,CreatedDate,CreatedBy,ModifiedDate,ModifiedBy,MetaKeywords,MetaDescription,Status,TopHot,ViewCount,Tagstring")] Content content) { if (ModelState.IsValid) { db.Entry(content).State = EntityState.Modified; //Set ModifiedBy, ModifiedDate content.ModifiedDate = DateTime.Now; UserLogin userLogin = (UserLogin)Session[CommonConstants.USER_SESSION]; content.ModifiedBy = userLogin.UserName; //Update entity if (new ContentDao().Update(content)) { SetAlert("Cập nhật thông tin bài viết thành công", AlertType.Success); return(RedirectToAction("Index", "Contents")); } else { ModelState.AddModelError("", "Cập nhật thông tin bài viết thất bại!!!"); } return(View("Index")); } ViewBag.CategoryID = new SelectList(db.Categories, "ID", "Name", content.CategoryID); return(View(content)); }
public virtual void Update(T entity) { dbSet.Attach(entity); dataContext.Entry(entity).State = EntityState.Modified; }
public void Update(Product product) { db.Entry(product).State = EntityState.Modified; db.SaveChanges(); }
public virtual void Update(int id, TEntity entity) { context.Entry(entity).State = EntityState.Modified; }
public void Edit(SanPham sp) { db.Entry(sp).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); }
public bool Update(Menu menu) { db.Entry(menu).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true); }
public void Update(Category category) { db.Entry(category).State = EntityState.Modified; db.SaveChanges(); }
public bool Update(Footer footer) { db.Entry(footer).State = EntityState.Modified; db.SaveChanges(); return(true); }