示例#1
0
        public bool InsertUser(LoginData loginData)
        {
            try
            {
                var salt = UserServices.GetSalt();


                var newUser = new User()
                {
                    email    = loginData.Email,
                    approach = loginData.Approach,
                    active   = false,
                    name     = loginData.Username,
                    password = BCrypt.Net.BCrypt.HashPassword(loginData.Password + salt),
                    salt     = salt,
                    role     = Roles.User
                };

                using (MainContext context = new MainContext(new DbContextOptionsBuilder <MainContext>().UseMySql(
                                                                 ConfigurationManager.AppSetting.GetConnectionString("DefaultConnection")
                                                                 ).Options))
                {
                    context.Add(newUser);
                    context.SaveChanges();

                    var shoppingCart = new ShoppingCard()
                    {
                        UserId = newUser.id
                    };
                    this.__context.Add(shoppingCart);
                    this.__context.SaveChanges();
                }
                if (!newUser.active)
                {
                    this.SendActivationMail(newUser);
                }
                ;
                return(true);
            }
            catch (System.Exception)
            {
                return(false);
            }
        }
示例#2
0
 public MainServices()
 {
     Users    = new UserServices();
     Register = new RegisterServices();
 }
示例#3
0
 public MainServices()
 {
     Users = new UserServices();
 }
示例#4
0
 public MainServices()
 {
     Users = new UserServices();
     Post  = new PostServices();
 }