Exemple #1
0
        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));
        }
Exemple #2
0
        public void SetRoleByUser(int userId, int roleId)
        {
            UserRole ur = new UserRole()
            {
                UserId = userId,
                RoleId = roleId,
            };

            db.UserRoles.Add(ur);
            db.SaveChanges();
        }
Exemple #3
0
        public ActionResult Create([Bind(Include = "Id,Name")] UserGroup userGroup)
        {
            if (ModelState.IsValid)
            {
                db.UserGroups.Add(userGroup);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(userGroup));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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();
        }