Пример #1
0
        public (ApiUser User, ApiLanguage Language) GetUserAndLanguage(string login, string password)
        {
            var languages = LanguageMapper.ConvertToApiEntitiesCollection(LanguageAdapter.GetAll()).ToList();

            DalUser dalUser    = null;
            var     dalUsers   = UserAdapter.GetAll($"login='******'");
            var     enumerable = dalUsers.ToList();

            if (enumerable.Count() == 0)
            {
                throw new NotImplementedException(); //TODO:
            }

            if (enumerable.ElementAt(0).Password == $"{password}")
            {
                dalUser = enumerable.ElementAt(0);
            }
            else
            {
                throw new NotImplementedException(); //TODO:
            }
            var language    = languages.Where(l => l.Id == dalUser.LanguageId).First();
            var userDetails = UserDetailsMapper.ConvertToApiEntity(UserDetailsAdapter.GetById(dalUser.DetailsId));

            UserMapper.Update(language, userDetails);

            var user = UserMapper.ConvertToApiEntity(dalUser);

            return(user, language);
        }
Пример #2
0
 public List <ApiLanguage> GetLanguages()
 {
     return(LanguageMapper.ConvertToApiEntitiesCollection(LanguageAdapter.GetAll()).ToList());
 }