Exemplo n.º 1
0
 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);
     }
 }
Exemplo n.º 2
0
        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));
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
 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));
 }
Exemplo n.º 6
0
 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));
 }
Exemplo n.º 7
0
 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));
 }
Exemplo n.º 9
0
 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));
 }
Exemplo n.º 10
0
 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));
 }
Exemplo n.º 11
0
 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());
 }
Exemplo n.º 12
0
 public void Edit(TinTuc tt)
 {
     try
     {
         db.Entry(tt).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception)
     {
     }
 }
Exemplo n.º 13
0
 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));
 }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
 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));
        }
Exemplo n.º 17
0
 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));
 }
Exemplo n.º 18
0
 public virtual void Update(T entity)
 {
     dbSet.Attach(entity);
     dataContext.Entry(entity).State = EntityState.Modified;
 }
Exemplo n.º 19
0
 public void Update(Product product)
 {
     db.Entry(product).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 20
0
 public virtual void Update(int id, TEntity entity)
 {
     context.Entry(entity).State = EntityState.Modified;
 }
Exemplo n.º 21
0
 public void Edit(SanPham sp)
 {
     db.Entry(sp).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 22
0
 public bool Update(Menu menu)
 {
     db.Entry(menu).State = System.Data.Entity.EntityState.Modified;
     db.SaveChanges();
     return(true);
 }
Exemplo n.º 23
0
 public void Update(Category category)
 {
     db.Entry(category).State = EntityState.Modified;
     db.SaveChanges();
 }
Exemplo n.º 24
0
 public bool Update(Footer footer)
 {
     db.Entry(footer).State = EntityState.Modified;
     db.SaveChanges();
     return(true);
 }