internal LoginOutEntity Translate(Login login) { LoginOutEntity loginOut = new LoginOutEntity() { Id = login.Id, Email = login.Email, Name = login.Name }; return(loginOut); }
public LoginOutEntity Authentication(string email, string password) { if (String.IsNullOrEmpty(email)) { return(null); } if (String.IsNullOrEmpty(password)) { return(null); } Login login = repositories.Login.GetAll() .FirstOrDefault(l => (l.Email.ToUpper() == email.ToUpper()) && (l.Password == password)); return(login == null ? null : Translate(login)); }
/// <summary> /// Проверяем и сохраняем логин. /// </summary> public LoginOutEntity Insert(LoginInEntity login) { string error = CheckEmail(login.Email); error += CheckUniqueEmail(login.Email); error += CheckName(login.Name); error += CheckPassword(login.Password); if (!String.IsNullOrEmpty(error)) { throw new MyException(error); } Login dataLogin = new Login(login.Name, login.Email, login.Password); repositories.Login.Save(dataLogin); CreateStartBalance(dataLogin); repositories.Save(); return(Translate(dataLogin)); }
/// <summary> /// Создаем начальный баланс /// </summary> /// <param name="login"></param> private void CreateStartBalance(Login login) { Transaction newTransaction = new Transaction(DateTime.Now, null, login.Id, StartBalance); repositories.Transaction.Save(newTransaction); }