Пример #1
0
        internal LoginOutEntity Translate(Login login)
        {
            LoginOutEntity loginOut = new LoginOutEntity()
            {
                Id    = login.Id,
                Email = login.Email,
                Name  = login.Name
            };

            return(loginOut);
        }
Пример #2
0
        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));
        }
Пример #3
0
        /// <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));
        }
Пример #4
0
        /// <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);
        }