public void AuthenticateUser(MemberLoginDetails details)
        {
            Account account = _accounts.GetAccountByUsername(details.UserName);

            if (account == null)
            {
                throw new Exception("Invalid username or password");
            }

            if (_hasher.SaltedPassword(details.Password, account.Salt) != account.Password)
            {
                throw new Exception("Invalid username or password");
            }
        }
        public bool RegisterMember(MemberLoginDetails memberLoginDetails)
        {
            GenericRepository <MemberLoginDetails> samplePracticeRepo = unitOfWork.GetRepoInstance <MemberLoginDetails>();

            samplePracticeRepo.Add(memberLoginDetails);
            unitOfWork.SaveChanges();
            if (memberLoginDetails.MemberId > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public IHttpActionResult RegisterMember([FromBody] MemberLoginDetails memberLoginDetails)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (memberLoginDetailsManager.RegisterMember(memberLoginDetails))
            {
                return(Ok());
            }
            else
            {
                return(NotFound());
            }
        }
        public void CreateNewAccount(MemberLoginDetails details)
        {
            if (_accounts.AccountExists(details.UserName))
            {
                throw new Exception("Account already exists");
            }

            string salt = _hasher.GetNewSalt();

            Account account = new Account()
            {
                DateCreated = DateTime.Now,
                UserName    = details.UserName,
                Password    = _hasher.SaltedPassword(details.Password, salt),
                Salt        = salt
            };

            _accounts.AddAccount(account);
        }