public ActionResult Add(Music.Model.EF.User user, HttpPostedFileBase IMG) { user.user_bin = false; if (user.user_active != true && user.user_active != false) { user.user_active = false; } //Chèn ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new FilesController(); img.AddImages(IMG, Common.Link.IMG_USER, code); user.user_img = code + IMG.FileName; } else { user.user_img = "notImg.png"; } if (usersDAO.Add(user)) { return(Redirect("/Admin/UsersAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }
public ActionResult Edit(Music.Model.EF.User user, HttpPostedFileBase IMG, string del) { User us = db.Users.Find(user.user_id); user.user_bin = false; user.user_active = true; user.user_option = true; user.user_datecreate = us.user_datecreate; user.user_datelogin = DateTime.Now; user.user_id = us.user_id; user.user_point = us.user_point; user.user_vip = us.user_vip; user.user_token = Guid.NewGuid().ToString(); user.user_datevip = us.user_datevip; user.user_deadline = us.user_deadline; user.user_note = us.user_note; user.user_code = us.user_code; if (user.user_active != true && user.user_active != false) { user.user_active = false; } //Chèn ảnh if (IMG != null) { var code = Guid.NewGuid().ToString(); var img = new FilesController(); img.AddImages(IMG, Common.Link.IMG_USER, code); user.user_img = code + IMG.FileName; } else { user.user_img = us.user_img; } if (usersDAO.Edit(user)) { return(Redirect("/Admin/UsersAdmin")); } else { return(Redirect(Common.Link.NOT_404)); } }