コード例 #1
0
        public void CreatePerson(string Login, string Password)
        {
            PersonDTO person = new PersonDTO()
            {
                Login = Login, Password = Password, Role = "user"
            };

            if (Database.Persons.GetAll().FirstOrDefault(x => x.Login == Login) == null)
            {
                Database.Persons.Create(CustomMapper.PersonMapper().Map <PersonDTO, Person>(person));
            }
            Database.Save();
        }
コード例 #2
0
        public PersonDTO GetPerson(string?username, string?password)
        {
            if (username == null)
            {
                throw new ValidationException("Не установлено значение username", "");
            }
            if (password == null)
            {
                throw new ValidationException("Не установлено значение password", "");
            }
            var person = Database.Persons.Get(CustomMapper.PersonMapper().Map <PersonDTO, Person>(new PersonDTO()
            {
                Login = username, Password = password
            }));

            if (person == null)
            {
                throw new ValidationException("Пользователь не найден", "");
            }

            return(new PersonDTO {
                Login = person.Login, Password = person.Password, Role = person.Role
            });
        }
コード例 #3
0
 public IEnumerable <PersonDTO> GetPersons()
 {
     return(CustomMapper.PersonMapper().Map <IEnumerable <Person>, IEnumerable <PersonDTO> >(Database.Persons.GetAll()));
 }
コード例 #4
0
 public ICollection <PersonDTO> GetPeople(string GetterLogin)
 {
     return(CustomMapper.PersonMapper().Map <ICollection <Person>, ICollection <PersonDTO> >(Database.Persons.GetAll().Except(Database.Persons.GetAll().Where(x => x.FriendsList.FirstOrDefault(x => x.Friend1_Login == GetterLogin || x.Friend2_Login == GetterLogin) != null)).ToList()));
 }