public ViewPersonModel ModelFromEntity(Person entity) { return(new ViewPersonModel(entity) { FullName = entity.FullName, IsGenderKnown = entity.Gender != Gender.Unknown, Gender = EnumDisplayer.GetResource(entity.Gender), GenderTooltip = GenderTooltip(entity.Gender), IsNationalityKnown = !string.IsNullOrEmpty(entity.Nationality), Nationality = entity.Nationality, Roles = string.Join(", ", entity.Roles.Select(EnumDisplayer.GetResource)), IsPlaceOfBirthKnown = !string.IsNullOrEmpty(entity.PlaceOfBirth), PlaceOfBirth = entity.PlaceOfBirth, IsDateOfBirthKnown = !entity.DateOfBirth.IsCompletelyUnknown, DateOfBirth = entity.DateOfBirth.ToString(), IsPlaceOfDeathKnown = !string.IsNullOrEmpty(entity.PlaceOfDeath), PlaceOfDeath = entity.PlaceOfDeath, IsDateOfDeathKnown = !entity.DateOfDeath.IsCompletelyUnknown, DateOfDeath = entity.DateOfDeath.ToString(), HasTags = entity.Tags.Any(), Tags = string.Join(", ", entity.Tags), ReviewText = entity.ReviewText, AuthoredBooks = entity.AuthoredBooks.Select(b => bookMapper.ModelFromEntity(b)), EditedBooks = entity.EditedBooks.Select(b => bookMapper.ModelFromEntity(b)), TranslatedBooks = entity.TranslatedBooks.Select(b => bookMapper.ModelFromEntity(b)), TranslatedStories = entity.TranslatedStories.Select(s => storyMapper.ModelFromEntity(s)), AuthoredStories = entity.AuthoredStories.Select(s => storyMapper.ModelFromEntity(s)) }); }
public ViewBookModel ModelFromEntity(Book entity) { var model = new ViewBookModel(entity) { Title = entity.Title, Subtitle = entity.Subtitle, LibraryStatus = EnumDisplayer.GetResource(entity.LibraryStatus), Tags = string.Join(", ", entity.Tags.Select(t => t.Name)), ShowPublishingInfo = (entity.Publisher != null) || (entity.Year.HasValue) || (!string.IsNullOrEmpty(entity.Iso639LanguageId)), Publisher = entity.Publisher.AsLinkablePublisherModel(), Isbn = entity.Isbn, Year = entity.Year, IsLanguageKnown = !string.IsNullOrEmpty(entity.Iso639LanguageId), Language = iso639LanguageDisplayer.GetLocalizedIso639LanguageResource(entity.Iso639LanguageId), Series = entity.Series.AsLinkableSeriesModel(), Editors = entity.Editors.Select(p => p.AsLinkablePersonModel()), Authors = entity.AllAuthors.Select(p => p.AsLinkablePersonModel()), CoverPeople = entity.Editors.Any() ? entity.Editors.Select(p => p.AsLinkablePersonModel()) : entity.AllAuthors.Select(p => p.AsLinkablePersonModel()), Translators = entity.AllTranslators.Select(p => p.AsLinkablePersonModel()), ReviewText = entity.ReviewText, ShowStoriesList = entity.BookType != BookType.Novel, Stories = entity.Stories.Select(s => new ViewStoryModel(s.Value)), BookType = LocalizeBookType(entity.BookType) }; if (entity.ReferenceBook != null) { model.ReferenceBook = ModelFromEntity(entity.ReferenceBook); } return(model); }
public void Can_Display_LibraryStatus_OnlyForReference() { var resource = EnumDisplayer.GetResource(LibraryStatus.OnlyForReference); // We don't care so much about casing, just that it's not the enum value ToString(), i.e. we're looking for a space in the string... Assert.That(resource.ToLower(), Is.EqualTo("just for reference")); }
public void Can_Display_Author_Role_Text() { var resource = EnumDisplayer.GetResource(Role.Author); Assert.That(resource, Is.EqualTo("Author")); }
public void Can_Display_Gender_Male_Symbol() { var resource = EnumDisplayer.GetResource(Gender.Male); Assert.That(resource, Is.EqualTo("♂")); }