Exemplo n.º 1
0
        public TagDetail Get(TagCriteria criteria)
        {
            using (var uow = UnitOfWorkFactory.Create <NovelContext>())
            {
                var service = new TagService(uow);
                var tag     = service.Get(criteria);

                var detail = JsonHelper.Deserialize <TagDetail>(JsonHelper.Serialize(tag));

                if (tag.TagType == R.TagType.GENRE || tag.TagType == R.TagType.CATEGORY || tag.TagType == R.TagType.CONTAIN)
                {
                    var sourceIDs = new[]
                    {
                        R.ConnectorType.SERIES_TAGCATEGORY,
                        R.ConnectorType.SERIES_TAGGENRE,
                        R.ConnectorType.SERIES_TAGCONTAIN
                    };
                    detail.Series = service.View <Series>().Where(w => w.IsDeleted == false)
                                    .Join(service.View <Connector>().Where(w => w.IsDeleted == false).Where(w => sourceIDs.Contains(w.ConnectorType) && w.TargetID == tag.ID),
                                          ts => ts.ID, c => c.SourceID,
                                          (ts, c) => ts).ToList();
                }
                return(detail);
            }
        }
Exemplo n.º 2
0
        private static TagCriteria ValidateTagCriteria(TagCriteria criterion)
        {
            if (!criterion.notifications && !criterion.feed)
            {
                return(null);
            }

            List <string> tags = new List <string>();

            foreach (var tag in criterion.tags)
            {
                if (Tools.ValidateTag(tag))
                {
                    tags.Add(tag);
                }
            }

            if (tags.Count == 0)
            {
                return(null);
            }

            criterion.tags = tags;

            return(criterion);
        }
Exemplo n.º 3
0
        // GET: Tag
        public ActionResult List(TagCriteria criteria)
        {
            criteria.Types = new[] { criteria.IDToInt };
            var searchModel = CreateSearchModel(criteria);

            searchModel.PagedListConfig.PageSize = 999;
            searchModel.PagedListConfig.OrderBy  = new Tag().PropertyName(m => m.Name);
            var pagedList = Facade <SearchFacade>().Search(searchModel);

            return(View(pagedList));
        }
Exemplo n.º 4
0
 public IList <Tag> SearchTag(TagCriteria criteria)
 {
     using (var uow = UnitOfWorkFactory.Create <NovelContext>())
     {
         var service = new TagService(uow);
         return(service.Search(new SearchModel <TagCriteria>
         {
             Criteria = criteria,
             PagedListConfig = new PagedListConfig()
             {
                 PageSize = 999999
             }
         }).Data);
     }
 }
Exemplo n.º 5
0
        public static void InsertOrReplaceTrackFollow(TrackFollow trackFollow)
        {
            // check user and track id
            if (trackFollow?.user_id == null || trackFollow?.track_id == null)
            {
                return;
            }

            // validate criteria
            List <TagCriteria> validatedTagCriteria = new List <TagCriteria>();

            // ensure the follow is in the user follow table toowoo woo
            InsertOrReplaceUserFollow(trackFollow.user_id, trackFollow.track_id);

            if (trackFollow.criteria != null && trackFollow.criteria.Count > 0)
            {
                foreach (var criterion in trackFollow.criteria.Take(12))
                {
                    criterion.feed          = trackFollow.feed_follow_type != null ? false : criterion.feed;
                    criterion.notifications = trackFollow.notifications_follow_type != null ? false : criterion.notifications;

                    TagCriteria validatedCriterion = ValidateTagCriteria(criterion);

                    if (validatedCriterion != null)
                    {
                        validatedTagCriteria.Add(validatedCriterion);
                    }
                }
            }

            trackFollow.criteria = validatedTagCriteria;

            // get basic follow modes
            trackFollow.feed_follow_type          = trackFollow.feed_follow_type == "all" || trackFollow.feed_follow_type == "none" ? trackFollow.feed_follow_type : GetFollowType(trackFollow.criteria, Enums.FollowMode.Feed);
            trackFollow.notifications_follow_type = trackFollow.notifications_follow_type == "all" || trackFollow.notifications_follow_type == "none" ? trackFollow.notifications_follow_type : GetFollowType(trackFollow.criteria, Enums.FollowMode.Notification);

            TableStorageRepository.InsertOrReplaceTrackFollow(TrackFollowToTableEntity(trackFollow));
        }
Exemplo n.º 6
0
        public Tag Get(TagCriteria criteria)
        {
            var qTag = View <Tag>().All();

            return(qTag.SingleOrDefault(w => w.ID == criteria.IDToInt));
        }
Exemplo n.º 7
0
        public ActionResult Detail(TagCriteria criteria)
        {
            var detail = Facade <TagFacade>().Get(criteria);

            return(View("Detail", detail));
        }
Exemplo n.º 8
0
 public ActionResult Add(TagCriteria criteria)
 {
     return(View(new TagForm {
         TagType = criteria.IDToInt
     }));
 }