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(); }
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 }); }
public IEnumerable <PersonDTO> GetPersons() { return(CustomMapper.PersonMapper().Map <IEnumerable <Person>, IEnumerable <PersonDTO> >(Database.Persons.GetAll())); }
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())); }