Core.Features.People.PersonFactory.CreatePerson C# (CSharp) Méthode

CreatePerson() public méthode

public CreatePerson ( string name, string email, string bio, Entities.Location location, ICollection categories = null, ICollection links = null ) : Entities.Person
name string
email string
bio string
location Entities.Location
categories ICollection
links ICollection
Résultat Entities.Person
        public Person CreatePerson(string name, string email, string bio, Location location, ICollection<CategoryField> categories = null, ICollection<LinkField> links = null)
        {
            var person = new Person
            {
                Bio = bio,
                Email = email,
                Joined = SystemClock.UtcNow,
                Location = location,
                Name = name,
                Slug = name.ToSlug(),
            };
            if (categories != null && categories.Count > 0)
            {
                person.AddCategories(categories);
            }
            if (links != null && links.Count > 0)
            {
                person.AddLinks(links);
            }
            return person;
        }

Usage Example

 public ShouldSavePersonWithLinks(ISession session, PersonFactory personFactory, ISpecimenBuilder specimenBuilder)
 {
     var links = specimenBuilder.CreateMany<LinkField>(_count).ToList();
     var fake = specimenBuilder.Create<Person>();
     var person = personFactory.CreatePerson(fake.Name, fake.Email, fake.Bio, Location.Georgetown, null, links);
     session.SaveOrUpdate(person);
     _personId = person.Id;
 }
All Usage Examples Of Core.Features.People.PersonFactory::CreatePerson
PersonFactory