public ActionResult Create([Bind(Include = "Id,Name,Price,Quantity,Description,Image,CategoryId,CreatedDate,ModifiedDate,Deleted,Promotion")] Product product) { if (ModelState.IsValid) { db.Products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }
public void SetRoleByUser(int userId, int roleId) { UserRole ur = new UserRole() { UserId = userId, RoleId = roleId, }; db.UserRoles.Add(ur); db.SaveChanges(); }
public ActionResult Create([Bind(Include = "Id,Name")] UserGroup userGroup) { if (ModelState.IsValid) { db.UserGroups.Add(userGroup); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userGroup)); }
public ActionResult Create([Bind(Include = "Id,Name,Birthday,Address,PhoneNumber,Email,Username,Password,Deleted,UserGroupId,AccessFailedCount")] User user) { if (ModelState.IsValid) { user.Deleted = false; user.AccessFailedCount = 3; db.Users.Add(user); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user)); }
public void DoRegister(User user) { var newUser = db.Users.Create(); newUser.Name = user.Name; newUser.Email = user.Email; newUser.Birthday = user.Birthday; newUser.Address = user.Address; newUser.Password = DataHelper.Instance.MD5Hash(user.Password); newUser.Username = user.Username; newUser.Deleted = false; newUser.UserGroupId = 3; newUser.AccessFailedCount = 3; newUser.PhoneNumber = user.PhoneNumber; db.Users.Add(newUser); db.SaveChanges(); }