Пример #1
0
 public IHttpActionResult Post([FromBody] LoginInEntity login)
 {
     try
     {
         LoginOutEntity loginOut = loginService.Insert(login);
         return(Ok(loginOut));
     }
     catch (MyException e)
     {
         return(Results(e));
     }
     catch (System.Exception e)
     {
         return(Results(e));
     }
 }
Пример #2
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));
        }