예제 #1
0
        public Person CreateUser(Guid personId, string login, string password, Groups groupName)
        {
            var group = this.groupRepository.GetEntitiesByQuery(v => v.Name == groupName.GetStringValue()).First();
            var personGroup = this.personGroupFactory.Create(Guid.NewGuid(), personId, group.Id, DateTime.Now);
            this.personGroupRepository.CreateOrUpdateEntity(personGroup);
            var credentials = this.credentialsFactory.Create(Guid.NewGuid(), personId, login, password);
            this.credentialsRepository.CreateOrUpdateEntity(credentials);

            return this.personRepository.GetEntityById(personId);
        }
예제 #2
0
        public Person Validate(string login, string password, Groups groupName)
        {
            var credentials = this.credentialsRepository.GetEntitiesByQuery(v => v.Login == login && v.Password == password)
                .FirstOrDefault();
            if (credentials == null)
            {
                return null;
            }

            var personGroup = this.personGroupRepository.GetEntitiesByQuery(v => v.PersonId == credentials.PersonId && v.Group.Name == groupName.GetStringValue()).FirstOrDefault();
            if (personGroup == null)
            {
                return null;
            }

            return this.personRepository.GetEntityById(credentials.PersonId);
        }