예제 #1
0
        public async Task <RequestResult> Register(AspNetUserVM model)
        {
            if (!ModelState.IsValid)
            {
                return(new RequestResult {
                    Message = "All fields are required", Status = false
                });
            }
            var user = usersBL.GetUserByEmail(model.Email);

            if (user == null)
            {
                AspNetUserDVM usern = new AspNetUserDVM
                {
                    AccessFailedCount = model.AccessFailedCount,
                    ConcurrencyStamp  = model.ConcurrencyStamp,
                    Email             = model.Email,
                    UserName          = model.UserName,
                    Password          = model.Password
                };

                bool result = await usersBL.AddUser(usern, "App User");

                if (result)
                {
                    return(new RequestResult {
                        Message = "Password has been changed.", Status = true
                    });
                }
            }
            return(new RequestResult {
                Message = "Unable to change your password. Please try again.", Status = false
            });
        }
        public IHttpActionResult AddUser([FromBody] SPAProjectManager.Models.Users user)
        {
            try
            {
                SPAProjectManager.Entities.Users usr = new SPAProjectManager.Entities.Users
                {
                    // UserID = user.UserID,
                    FirstName  = user.FirstName,
                    LastName   = user.LastName,
                    EmployeeID = user.EmployeeID
                };

                _userBL.AddUser(usr);
                return(Ok());
            }
            catch (Exception ex)
            {
                return(InternalServerError());
            }
        }