Exemplo n.º 1
0
        public static void CreateUser(User request, IDacUser dacUser)
        {
            if (dacUser.Single(u => u.Username.Equals(request.Username)) != null)
            {
                throw new Exception("username already used");
            }

            if (dacUser.Single(u => u.Email.Equals(request.Email)) != null)
            {
                throw new Exception("email already used");
            }

            var user = new Data.Entity.User
            {
                Id       = request.Id,
                Username = request.Username,
                Password = Crypt.ToSHA256(request.Password),
                Name     = request.Name,
                Email    = request.Email,
                Gender   = request.Gender,
                Phone    = request.Phone,
                Role     = request.Role
            };

            dacUser.Insert(user);
            dacUser.Commit();
        }
Exemplo n.º 2
0
 public AuthController(IDistributedCache distributedCache, IDacUser dacUser, IConfiguration configuration)
 {
     _distributedCache = distributedCache;
     _dacUser          = dacUser;
     _configuration    = configuration;
 }
Exemplo n.º 3
0
 public UserController(IDistributedCache distributedCache, IDacUser dacUser)
 {
     _dacUser = dacUser;
 }