Пример #1
0
        public IHttpActionResult AddUser(UserMdel newuser)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            AuthBL          AuthBusLayer = new AuthBL();
            ApplicationUser OldUser      = AuthBusLayer.FindUser(newuser.UserName, newuser.Password);

            if (OldUser != null)
            {
                return(BadRequest("Exist Befor"));
            }

            IdentityResult res = AuthBusLayer.CreateUser(newuser);

            if (res.Succeeded)
            {
                return(Ok("User"));
            }
            string Errors = "";

            foreach (var item in res.Errors)
            {
                Errors += item + " ";
            }
            return(BadRequest(Errors));
        }