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); }
public void SetCurrentUser(Users user) { HttpContext.Current.Session.Add("CurrentUser", user); }
partial void DeleteUsers(Users instance);
partial void UpdateUsers(Users instance);
partial void InsertUsers(Users instance);
public HttpResponseMessage UpdateUser(Users user) { _users.UpdateUser(user); return SuccessResult(); }
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(); }
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)); }