public ActionResult <List <Group> > PreviewFilterChanges(Filter.FullFilter filter)
        {
            SVR_GroupFilter gf = filter.ToServerModel();

            gf.CalculateGroupsAndSeries();

            if (!gf.GroupsIds.ContainsKey(User.JMMUserID))
            {
                return(new List <Group>());
            }
            return(gf.GroupsIds[User.JMMUserID].Select(a => RepoFactory.AnimeGroup.GetByID(a))
                   .Where(a => a != null).GroupFilterSort(gf).Select(a => new Group(HttpContext, a)).ToList());
        }
        public ActionResult <List <Group> > PreviewFilterChanges(Filter.FullFilter body)
        {
            var groupFilter = body.ToServerModel();

            groupFilter.CalculateGroupsAndSeries();

            if (!groupFilter.GroupsIds.TryGetValue(User.JMMUserID, out var groupIDs))
            {
                return(new List <Group>());
            }

            return(groupIDs
                   .Select(a => RepoFactory.AnimeGroup.GetByID(a))
                   .Where(a => a != null)
                   .OrderByGroupFilter(groupFilter)
                   .Select(a => new Group(HttpContext, a))
                   .ToList());
        }
        public ActionResult <Filter> SaveFilter(Filter.FullFilter filter)
        {
            SVR_GroupFilter gf = null;

            if (filter.IDs.ID != 0)
            {
                gf = RepoFactory.GroupFilter.GetByID(filter.IDs.ID);
                if (gf == null)
                {
                    return(BadRequest("No Filter with ID"));
                }
                if (gf.Locked == 1)
                {
                    return(BadRequest("Filter is Locked"));
                }
            }
            gf = filter.ToServerModel(gf);
            gf.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(gf);

            return(new Filter(HttpContext, gf));
        }
        public ActionResult <Filter> SaveFilter(Filter.FullFilter body)
        {
            SVR_GroupFilter groupFilter = null;

            if (body.IDs.ID != 0)
            {
                groupFilter = RepoFactory.GroupFilter.GetByID(body.IDs.ID);
                if (groupFilter == null)
                {
                    return(NotFound(FilterNotFound));
                }
                if (groupFilter.Locked == 1)
                {
                    return(Forbid("Filter is Locked"));
                }
            }
            groupFilter = body.ToServerModel(groupFilter);
            groupFilter.CalculateGroupsAndSeries();
            RepoFactory.GroupFilter.Save(groupFilter);

            return(new Filter(HttpContext, groupFilter));
        }