Example #1
0
        public async Task <IHttpActionResult> Register(DataModel.User model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var user = new ApplicationUser()
            {
                UserName = model.Email, Email = model.Email
            };

            IdentityResult result = await UserManager.CreateAsync(user, model.Password);

            if (!result.Succeeded)
            {
                return(GetErrorResult(result));
            }
            using (var db = new VetContext())
            {
                model.UserId = Guid.NewGuid();
                if (model.Role == 0)
                {
                    model.Role = 2;  //Указываем стандартную роль при регистрации
                }
                db.Users.Add(model); //Добавляем модель юзера в собственную бд
                db.SaveChanges();
            }
            return(Ok());
        }
Example #2
0
 public void InsertUser(DataModel.User user)
 {
     try
     {
         UserBll userBll = new UserBll();
         int     result  = userBll.InsertUser(user);
         if (result > 0)
         {
             MessageBox.Show("Successfully Saved.");
             ClearUser(user);
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
 /// <summary>
 /// Create a new User object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="login">Initial value of the Login property.</param>
 /// <param name="password">Initial value of the Password property.</param>
 /// <param name="modifyDate">Initial value of the ModifyDate property.</param>
 /// <param name="createDate">Initial value of the CreateDate property.</param>
 public static User CreateUser(global::System.Guid id, global::System.String login, global::System.String password, global::System.DateTime modifyDate, global::System.DateTime createDate)
 {
     User user = new User();
     user.Id = id;
     user.Login = login;
     user.Password = password;
     user.ModifyDate = modifyDate;
     user.CreateDate = createDate;
     return user;
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the User EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToUser(User user)
 {
     base.AddObject("User", user);
 }