public bool ValidateUser(UserModel model)
 {
     using (_context = new karrykartEntities())
     {
         var p = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(model.pwd));
         return(_context.Users.Any(x => x.EmailAddress == model.user && x.Password == p));
     }
 }
Exemple #2
0
        public User IsAuthenticatedUser(LoginModel model)
        {
            _context      = new karrykartEntities();
            model.UserPwd = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(model.UserPwd));
            var user = _context.Users.Where(x => x.EmailAddress == model.UserID || x.Mobile == model.UserID).FirstOrDefault();

            _context = null;
            return((user != null) ? (user.Active.Value && user.Password == model.UserPwd) ? user : null : null);
        }
        public bool ChangePassword(UserSignUpModel userModel)
        {
            using (_context = new karrykartEntities()) {
                var user = _context.Users.Where(u => u.EmailAddress == userModel.user).FirstOrDefault();

                if (user != null)
                {
                    user.Password              = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(userModel.pwd));
                    user.LastUpdated           = DateTime.Now;
                    _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
                    _context.SaveChanges();
                    return(true);
                }
                return(false);
            }
        }
Exemple #4
0
        public bool SetPassword(LoginModel model)
        {
            _context = new karrykartEntities();

            var user = _context.Users.Where(x => x.EmailAddress == model.UserID).FirstOrDefault();

            if (user != null)
            {
                user.Password = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(model.UserPwd));
                _context.Entry(user).State = System.Data.Entity.EntityState.Modified;
                _context.SaveChanges();
            }
            _context     = null;
            _emailHelper = new EmailHelper();

            var IsMessageSent = SendChangePasswordMessage(model.UserID);

            _emailHelper = null;
            return(IsMessageSent);
        }
        public User SignUpUser(UserSignUpModel user)
        {
            _context = new karrykartEntities();
            if (!(_context.Users.Where(x => x.EmailAddress == user.user).Count() > 0))
            {
                var userToCreate = new User()
                {
                    DateCreated  = DateTime.Now,
                    EmailAddress = user.user,
                    // Mobile = CommonHelper.IsMobile(model.UserIdentifier) ? model.UserIdentifier : string.Empty,
                    Password        = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(user.pwd)),
                    UserID          = Guid.NewGuid(),
                    LastUpdated     = DateTime.Now,
                    RoleID          = CommonHelper.CustomerType.Customer,
                    Active          = false,
                    ProfileComplete = false
                };
                var userDet = new UserDetail()
                {
                    UserID    = userToCreate.UserID,
                    FirstName = user.Name.Split(' ')[0],
                    LastName  = user.Name.Split(' ').Length > 1?user.Name.Split(' ')[1]:null
                };

                var userAddress = new UserAddressDetail()
                {
                    UserID = userToCreate.UserID
                };


                _context.Users.Add(userToCreate);
                _context.UserDetails.Add(userDet);
                _context.UserAddressDetails.Add(userAddress);
                _context.SaveChanges();
                return(userToCreate);
            }

            _context = null;

            return(null);
        }
Exemple #6
0
        public User RegisterUser(RegisterModel model)
        {
            _context = new karrykartEntities();
            if (!(_context.Users.Where(x => x.EmailAddress == model.UserIdentifier || x.Mobile == model.UserIdentifier).Count() > 0))
            {
                var user = new User()
                {
                    DateCreated     = DateTime.Now,
                    EmailAddress    = CommonHelper.IsEmail(model.UserIdentifier) ? model.UserIdentifier : string.Empty,
                    Mobile          = CommonHelper.IsMobile(model.UserIdentifier) ? model.UserIdentifier : string.Empty,
                    Password        = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(model.UserPwd)),
                    UserID          = Guid.NewGuid(),
                    LastUpdated     = DateTime.Now,
                    RoleID          = CommonHelper.CustomerType.Customer,
                    Active          = false,
                    ProfileComplete = false
                };
                var userDet = new UserDetail()
                {
                    UserID = user.UserID
                };

                var userAddress = new UserAddressDetail()
                {
                    UserID = user.UserID
                };


                _context.Users.Add(user);
                _context.UserDetails.Add(userDet);
                _context.UserAddressDetails.Add(userAddress);
                _context.SaveChanges();
                return(user);
            }

            _context = null;

            return(null);
        }