public IHttpActionResult Post(UserVM request)
        {
            if (IsValid(request))
            {
                User user = GetMappedUser(request);
                if (this.userService.CreateUser(user))
                {
                    List<UserVM> users = GetUsers();
                    return this.Ok(users);
                }

                return this.BadRequest();
            }

            return this.BadRequest("User is not valid.");
        }
        public IHttpActionResult Put(UserVM request)
        {
            if (IsValid(request))
            {
                User user = this.userService.FindUser(request.Id);
                if (user == null)
                {
                    return this.NotFound();
                }

                user.Name = request.Name;
                user.Email = request.Email;

                if (this.userService.EditUser(user))
                {
                    List<UserVM> users = GetUsers();
                    return this.Ok(users);
                }

                return this.BadRequest();
            }

            return this.BadRequest("User is not valid.");
        }
 private static bool IsValid(UserVM user)
 {
     return !user.Name.IsNullOrEmpty() && !user.Email.IsNullOrEmpty();
 }
 private static User GetMappedUser(UserVM request)
 {
     return new User
     {
         Name = request.Name,
         Email = request.Email,
         IsAdmin = false,
         Password = request.Password
     };
 }