Skip to content

Commit

Permalink
(#87) fix issue with mongo document serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
eggwhat committed May 17, 2024
1 parent d8f28c9 commit f919761
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ public IEnumerable<Organization> SubOrganizations
private set => _subOrganizations = new HashSet<Organization>(value);
}

public Organization(Guid id, string name, IEnumerable<Organizer> organizers = null,
IEnumerable<Organization> subOrganizations = null)
public Organization(Guid id, string name, IEnumerable<Organizer> organizationOrganizers = null,
IEnumerable<Organization> organizations = null)
{
Id = id;
Name = name;
Organizers = organizers ?? Enumerable.Empty<Organizer>();
SubOrganizations = subOrganizations ?? Enumerable.Empty<Organization>();
Organizers = organizationOrganizers ?? Enumerable.Empty<Organizer>();
SubOrganizations = organizations ?? Enumerable.Empty<Organization>();
}

public void AddOrganizer(Guid organizerId)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ namespace MiniSpace.Services.Organizations.Infrastructure.Mongo.Documents
public static class Extensions
{
public static Organization AsEntity(this OrganizationDocument document)
=> new Organization(document.Id, document.Name, document.Organizers, document.SubOrganizations);
=> new Organization(document.Id, document.Name, document.Organizers, document.SubOrganizations.Select(o => o.AsEntity()));

public static OrganizationDocument AsDocument(this Organization entity)
=> new OrganizationDocument()
{
Id = entity.Id,
Name = entity.Name,
Organizers = entity.Organizers,
SubOrganizations = entity.SubOrganizations
SubOrganizations = entity.SubOrganizations.Select(o => o.AsDocument())
};

public static OrganizationDto AsDto(this OrganizationDocument document)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public class OrganizationDocument: IIdentifiable<Guid>
public Guid Id { get; set; }
public string Name { get; set; }
public IEnumerable<Organizer> Organizers { get; set; }
public IEnumerable<Organization> SubOrganizations { get; set; }
public IEnumerable<OrganizationDocument> SubOrganizations { get; set; }
}
}

0 comments on commit f919761

Please sign in to comment.