Exemple #1
0
        public ActionResult Detail(SeriesCriteria criteria)
        {
            criteria.ByUserID = UserSession.UserID;
            var detail = Facade <SeriesFacade>().GetSeries(criteria);

            // log views
            var viewForm = new ViewForm {
                UserID = criteria.ByUserID, SourceID = detail.ID, SourceTable = R.SourceTable.SERIES
            };

            Facade <UserActionFacade>().Viewing(viewForm);

            return(View(detail));
        }
Exemple #2
0
        public IList <Series> SearchSeries(SeriesCriteria criteria)
        {
            using (var uow = UnitOfWorkFactory.Create <NovelContext>())
            {
                var qSeries = uow.Repository <Series>().All();

                if (!string.IsNullOrWhiteSpace(criteria.Query))
                {
                    qSeries = qSeries.Where(w => w.Title.Contains(criteria.Query));
                }

                return(qSeries.ToList());
            }
        }
Exemple #3
0
        public ActionResult PreviousChapter(SeriesCriteria criteria, DateTime?date)
        {
            if (date.HasValue)
            {
                var detail  = Facade <SeriesFacade>().GetSeries(criteria);
                var release = detail.Releases.OrderByDescending(o => o.Date).FirstOrDefault(w => w.Date < date.Value);
                if (release == null)
                {
                    return(View(detail));
                }

                return(RedirectPermanent(Url.Action("Detail", "Release", new { ID = release.ID, Seo = release.Title.ToSeo() })));
            }
            return(null);
        }
Exemple #4
0
        public ActionResult Index(SeriesCriteria criteria)
        {
            var searchModel = CreateSearchModel(criteria);
            var pagedList   = Facade <SearchFacade>().Search(searchModel);

            // alternative version
            if (!string.IsNullOrWhiteSpace(criteria.Alt))
            {
                var feedItems = pagedList.Data.Select(s => new FeedGrid
                {
                    InsertedDate = s.InsertedDate,
                    UpdatedDate  = s.UpdatedDate,
                    Title        = s.Title,
                    Url          = Url.Action("Detail", "Series", new { ID = s.ID, Seo = s.Title.ToSeo() }),
                    Content      = s.Synopsis
                });
                return(FeedGenerator(feedItems, criteria.Alt));
            }

            return(View(pagedList));
        }
Exemple #5
0
        public SeriesDetail Get(SeriesCriteria criteria)
        {
            var qSeries = View <Series>().All();

            if (criteria.IDToInt > 0)
            {
                qSeries = qSeries.Where(w => w.ID == criteria.IDToInt);
            }

            var series = qSeries.SingleOrDefault();

            if (series == null)
            {
                return(null);
            }

            var detail = new SeriesDetail();

            MapProperty(series, detail);

            return(detail);
        }
 /// <summary>
 ///     Fetches a list of comic series, with optional filters
 /// </summary>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <returns></returns>
 public async Task <Response <List <Series> > > GetAllSeriesAsync(int?limit = null, int?offset = null,
                                                                  SeriesCriteria criteria = null)
 {
     return(await _seriesService.GetAllAsync(limit, offset, criteria));
 }
 /// <summary>
 ///     Fetches a list of comic series in which the specified story takes place, with optional filters
 /// </summary>
 /// <param name="storyId">The story ID.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <returns></returns>
 public async Task <Response <List <Series> > > GetStorySeriesAsync(int storyId, int?limit = null,
                                                                    int?offset             = null, SeriesCriteria criteria = null)
 {
     return(await _seriesService.GetByStoryAsync(storyId, limit, offset, criteria));
 }
 /// <summary>
 ///     Fetches a list of comic series in which the specified event takes place, with optional filters
 /// </summary>
 /// <param name="eventId">The event ID.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <returns></returns>
 public async Task <Response <List <Series> > > GetEventSeriesAsync(int eventId, int?limit = null,
                                                                    int?offset             = null, SeriesCriteria criteria = null)
 {
     return(await _seriesService.GetByEventAsync(eventId, limit, offset, criteria));
 }
 /// <summary>
 ///     Fetches a list of comic series in which the specified creator's work appears, with optional filters
 /// </summary>
 /// <param name="creatorId">The creator ID.</param>
 /// <param name="limit">Limit the result set to the specified number of resources.</param>
 /// <param name="offset">Skip the specified number of resources in the result set.</param>
 /// <param name="criteria">Filter the result set by the specified criteria.</param>
 /// <returns></returns>
 public async Task <Response <List <Series> > > GetCreatorSeriesAsync(int creatorId, int?limit = null,
                                                                      int?offset = null, SeriesCriteria criteria = null)
 {
     return(await _seriesService.GetByCreatorAsync(creatorId, limit, offset, criteria));
 }
Exemple #10
0
 internal async Task <Response <List <Series> > > GetByStoryAsync(int storyId, int?limit = null, int?offset = null, SeriesCriteria criteria = null)
 {
     return(await GetList(string.Format(UrlSuffixStorySeries, storyId), limit, offset, criteria));
 }
Exemple #11
0
 internal async Task <Response <List <Series> > > GetByCharacterAsync(int characterId, int?limit = null, int?offset = null, SeriesCriteria criteria = null)
 {
     return(await GetList(string.Format(UrlSuffixCharacterSeries, characterId), limit, offset, criteria));
 }
Exemple #12
0
 internal async Task <Response <List <Series> > > GetAllAsync(int?limit = null, int?offset = null, SeriesCriteria criteria = null)
 {
     return(await GetList(UrlSuffixAllSeries, limit, offset, criteria));
 }
Exemple #13
0
        public SeriesDetail GetSeries(SeriesCriteria criteria)
        {
            using (var uow = UnitOfWorkFactory.Create <NovelContext>())
            {
                var service = new SeriesService(uow);
                var detail  = service.Get(criteria);

                var connectorTypes = new[]
                {
                    R.ConnectorType.SERIES_TAGCATEGORY,
                    R.ConnectorType.SERIES_TAGGENRE,
                    R.ConnectorType.SERIES_TAGTHEME,
                    R.ConnectorType.SERIES_TAGCONTAIN,
                    R.ConnectorType.SERIES_GROUP,
                    R.ConnectorType.SERIES_AUTHOR,
                    R.ConnectorType.SERIES_PUBLISHER,
                    R.ConnectorType.SERIES_GLOSSARY,
                    R.ConnectorType.SERIES_FEED,
                    R.ConnectorType.SERIES_USERLIST,
                };
                var connectors = service.View <Connector>().Where(w => w.IsDeleted == false && connectorTypes.Contains(w.ConnectorType) && w.SourceID == detail.ID).ToList();

                var tagTypes = new[] { R.TagType.CATEGORY, R.TagType.GENRE, R.TagType.CONTAIN };
                var tags     = service.View <Tag>().Where(w => tagTypes.Contains(w.TagType)).ToList();

                detail.Categories = tags.Where(w => w.TagType == R.TagType.CATEGORY && connectors.Any(a => a.ConnectorType == R.ConnectorType.SERIES_TAGCATEGORY && a.TargetID == w.ID)).ToList();

                detail.Genres = tags.Where(w => w.TagType == R.TagType.GENRE && connectors.Any(a => a.ConnectorType == R.ConnectorType.SERIES_TAGGENRE && a.TargetID == w.ID)).ToList();

                detail.Contains = tags.Where(w => w.TagType == R.TagType.CONTAIN && connectors.Any(a => a.ConnectorType == R.ConnectorType.SERIES_TAGCONTAIN && a.TargetID == w.ID)).ToList();

                var authorIDs = connectors.Where(w => w.ConnectorType == R.ConnectorType.SERIES_AUTHOR).Select(s => s.TargetID).ToList();
                detail.Authors = service.View <Author>().Where(w => authorIDs.Contains(w.ID)).ToList();

                var groupIDs = connectors.Where(w => w.ConnectorType == R.ConnectorType.SERIES_GROUP).Select(s => s.TargetID).ToList();
                detail.Groups = service.View <Group>().Where(w => groupIDs.Contains(w.ID)).ToList();

                detail.Summarize = service.View <Summarize>().Where(w => w.SourceTable == R.SourceTable.SERIES && w.SourceID == detail.ID).SingleOrDefault() ?? new Summarize();

                // get data for user lists
                detail.Connectors = connectors;

                detail.UserLists = service.View <UserList>().Where(w => w.IsDeleted == false && w.UserID == criteria.ByUserID)
                                   .OrderBy(o => o.Priority == 0 ? int.MaxValue : o.Priority).ThenBy(o => o.Name).ToList();

                detail.Releases = service.View <Release>().Where(w => w.SeriesID == detail.ID).ToList();

                detail.Feeds = service.View <Connector>()
                               .Where(w => w.ConnectorType == R.ConnectorType.SERIES_FEED && w.SourceID == detail.ID)
                               .Join(service.View <Feed>().All(), c => c.TargetID, f => f.ID, (c, f) => f).ToList();

                detail.Glossaries = service.View <Glossary>().Where(w => w.SourceTable == R.SourceTable.SERIES && w.SourceID == detail.ID).ToList();

                detail.UserAction = new UserActionFacade().Get(new ViewForm {
                    UserID = criteria.ByUserID, SourceID = detail.ID, SourceTable = R.SourceTable.SERIES
                });

                detail.Akas = service.View <Aka>().Where(w => w.IsDeleted == false && w.SourceID == detail.ID && w.SourceTable == R.SourceTable.SERIES).ToList();
                return(detail);
            }
        }
Exemple #14
0
        public JsonResult Series(SeriesCriteria criteria)
        {
            var results = Facade <QueryFacade>().SearchSeries(criteria);

            return(Json(results, JsonRequestBehavior.AllowGet));
        }
Exemple #15
0
        public void ToDictionary_ReturnsCorrectDictionary()
        {
            // Arrange
            var sut = new SeriesCriteria
            {
                Title           = "TestTitle159",
                TitleStartsWith = "Tr",
                StartYear       = 2005,
                ModifiedSince   = new DateTime(2015, 1, 15, 8, 59, 21),
                Characters      = new List <int> {
                    1, 2, 3
                },
                Comics = new List <int> {
                    21, 22, 23
                },
                Creators = new List <int> {
                    11, 12, 13
                },
                Events = new List <int> {
                    0, 56
                },
                Stories = new List <int> {
                    0
                },
                Contains = new List <Format> {
                    Format.Comic, Format.Digest
                },
                SeriesType = SeriesType.OneShot,
                OrderBy    = new List <SeriesOrder>()
            };

            // Act
            var result = sut.ToDictionary();

            // Assert
            Assert.AreEqual(11, result.Count);

            Assert.Contains(ParameterTitle, result.Keys);
            Assert.Contains(ParameterTitleStartsWith, result.Keys);
            Assert.Contains(ParameterStartYear, result.Keys);
            Assert.Contains(ParameterModifiedSince, result.Keys);
            Assert.Contains(ParameterCharacters, result.Keys);
            Assert.Contains(ParameterComics, result.Keys);
            Assert.Contains(ParameterCreators, result.Keys);
            Assert.Contains(ParameterEvents, result.Keys);
            Assert.Contains(ParameterStories, result.Keys);
            Assert.Contains(ParameterContains, result.Keys);
            Assert.Contains(ParameterSeriesType, result.Keys);

            Assert.IsFalse(result.Keys.Contains(ParameterOrderBy));

            Assert.AreEqual(sut.Title, result[ParameterTitle]);
            Assert.AreEqual(sut.TitleStartsWith, result[ParameterTitleStartsWith]);
            Assert.AreEqual(sut.StartYear.ToString(), result[ParameterStartYear]);
            Assert.AreEqual(sut.ModifiedSince.Value.ToString(ParameterDateTimeFormat), result[ParameterModifiedSince]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Comics), result[ParameterComics]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Stories), result[ParameterStories]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Characters), result[ParameterCharacters]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Creators), result[ParameterCreators]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Events), result[ParameterEvents]);
            Assert.AreEqual(string.Join(ParameterListSeparator, sut.Contains.Select(c => c.GetStringValue())), result[ParameterContains]);
            Assert.AreEqual(sut.SeriesType.GetStringValue(), result[ParameterSeriesType]);
        }