Ejemplo n.º 1
0
        public Task <AdminUser> AddAdminUser(AdminUser adminUser)
        {
            var adminUserExist = _adminUserRepository.GetByEmail(adminUser.Email).Result;

            if (adminUserExist != null)
            {
                throw new ArgumentException(string.Format("User with Email {0} already used", adminUser.Email), "email");
            }

            _adminUserRepository.Add(adminUser);
            var saved = _adminUserRepository.SaveChangesAsync().Result;

            if (!saved)
            {
                return(null);
            }

            return(_adminUserRepository.Get(adminUser.Id));
        }
Ejemplo n.º 2
0
 public AdminUserDto GetByEmail(string email)
 {
     try
     {
         return(rep.GetByEmail(email).MapTo <AdminUserDto>());
     }
     catch (Exception)
     {
         throw;
     }
 }
Ejemplo n.º 3
0
        public AdminUser ValidateAdminUser(string email, string password)
        {
            var adminUser = _adminUserRepository.GetByEmail(email).Result;

            if (adminUser == null)
            {
                return(null);
            }

            //adminUser = _adminUserRepository.Get(adminUser.Id, "AdminUserRoles.AdminUser").Result;

            if (CompareHashedPassword(password, adminUser.Password))
            {
                return(adminUser);
            }
            else
            {
                return(null);
            }
        }