Пример #1
0
        public HttpResponseMessage Registration(Users user)
        {
            if (_users.GetFirstOrDefault(z=>z.Login == user.Login) != null) return ErrorResult(Constants.Login);
            if (_users.GetFirstOrDefault(z=>z.Email == user.Email) != null) return ErrorResult(Constants.Email);

            var passwordHashMd5 = HashHelper.ComputeHash(user.Password, "MD5", Converter.GetBytes(Constants.Salt));

            user.Password = passwordHashMd5;
            user.Id = Guid.NewGuid();
            user.CreateDate = DateTime.Now;
            _users.CreateItem(user);

            SetCurrentUser(user);
            _authenticationProvider.SignIn(user.Login, true);

            return SuccessResult(user);


            //Help

            //string passwordHashSha1 = HashHelper.ComputeHash(user.Password, "SHA1", null);
            //string passwordHashSha256 = HashHelper.ComputeHash(user.Password, "SHA256", null);
            //string passwordHashSha384 = HashHelper.ComputeHash(user.Password, "SHA384", null);
            //string passwordHashSha512 = HashHelper.ComputeHash(user.Password, "SHA512", null);
        }
Пример #2
0
 public void SetCurrentUser(Users user)
 {
     HttpContext.Current.Session.Add("CurrentUser", user);
 }
Пример #3
0
 partial void DeleteUsers(Users instance);
Пример #4
0
 partial void UpdateUsers(Users instance);
Пример #5
0
 partial void InsertUsers(Users instance);
Пример #6
0
 public HttpResponseMessage UpdateUser(Users user)
 {
     _users.UpdateUser(user);
     return SuccessResult();
 }
Пример #7
0
 public HttpResponseMessage PayForBasket(Users user)
 {
     var basket = _basketRepository.GetFirstOrDefault(z => z.UserId == user.Id && z.DateSuccess == null);
     if (basket == null) return ErrorResult();
     _basketRepository.SuccessBasket(basket);
     return SuccessResult();
 }
Пример #8
0
 public HttpResponseMessage BasketInfo(Users user)
 {
     var basket = _basketRepository.GetFirstOrDefault(z => z.UserId == user.Id && z.DateSuccess == null);
     if (basket == null) return ErrorResult("no basket");
     return SuccessResult(GetBasketInfoById(basket.Id));
 }