예제 #1
0
        public ActionResult Create(int id, [Bind("ID", "Name", "Gender")] User user)
        {
            try
            {
                var errorMessage = GetErrorIfInvalid(user);

                if (!string.IsNullOrWhiteSpace(errorMessage))
                {
                    return(RedirectToAction("Index", "Error", new { error = errorMessage }));
                }

                var userToAdd = new User
                {
                    ID     = user.ID,
                    Name   = user.Name,
                    Gender = user.Gender
                };

                _userBl.AddUser(user.ID, user.Name, user.Gender);

                return(RedirectToAction("Index", "Admin"));
            }
            catch
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
예제 #2
0
        public ActionResult Create(int id, [Bind("Gender", "UserName", "Password", "Email")] User user)
        {
            try
            {
                var errorMessage = GetErrorIfInvalid(user, true);

                if (!string.IsNullOrWhiteSpace(errorMessage))
                {
                    return(RedirectToAction("Index", "Error", new { error = errorMessage }));
                }

                var userToAdd = new User
                {
                    Gender   = user.Gender,
                    UserName = user.UserName,
                    Password = user.Password,
                    Email    = user.Email,
                    IsAdmin  = false
                };

                _userBl.AddUser(userToAdd);
                SetUserInSession(userToAdd.UserName, user.IsAdmin);

                return(RedirectToAction("Index", "About"));
            }
            catch
            {
                return(RedirectToAction("Index", "Error"));
            }
        }
예제 #3
0
        public string PostMoreAlbums([FromBody] User user)
        {
            int usersCreated = userBl.AddUser(user);

            if (usersCreated != 0)
            {
                return(usersCreated + " Object created!");
            }
            return("No object created");
        }
예제 #4
0
 public bool AddUser(User user)
 {
     return(_userBl.AddUser(user));
 }