Пример #1
0
        public ResponseInfoModel Showlist([FromUri] GetPublicityShowListInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                var outputList = _PublicityContentService.GetShowList(input);
                json.Result = new ListInfo()
                {
                    List = outputList
                };
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/publicity/showlist", LocalizationConst.QueryFail);
            }
            return(json);
        }
Пример #2
0
        public List <GetPublicityShowListOutput> GetShowList(GetPublicityShowListInput input)
        {
            string publishUrl = ConfigurationManager.AppSettings["PulishAddres"];

            var temp = from a in db.PublicityContents
                       join b in db.ArticleAttaches on a.AttachGuid equals b.ArticleGuid into t1
                       from tt1 in t1.DefaultIfEmpty()
                       join c in db.PublicityCategories on a.PublicityCategoryID equals c.ID
                       where a.PublishTime <= DateTime.Now && a.ExpiredTime >= DateTime.Now &&
                       c.PublicityTypesID == input.PublicityTypesID &&
                       (input.PublicityCateID == 0 || a.PublicityCategoryID == input.PublicityCateID)
                       orderby a.OrderID, a.PublishTime descending
                select new
            {
                a,
                tt1.AttachUrl,
                c.PublicityCategoryName
            };

            if (input.Top != 0)
            {
                temp = temp.Skip(0).Take(input.Top);
            }

            var list = temp.Select(s => new GetPublicityShowListOutput()
            {
                AttachUrl             = string.IsNullOrEmpty(s.AttachUrl)? "": publishUrl + s.AttachUrl,
                ID                    = s.a.ID,
                NavType               = s.a.NavType,
                NavUrl                = s.a.NavUrl ?? "",
                OrderID               = s.a.OrderID,
                PublicityCategoryName = s.PublicityCategoryName ?? "",
                Remark                = s.a.Remark ?? "",
                PublishTime           = s.a.PublishTime,
                PublicityName         = s.a.PublicityName ?? ""
            }).AsNoTracking().ToList();

            return(list);
        }
Пример #3
0
        public ResponseInfoModel ShowListByName([FromUri] GetPublicityShowNameListInput input)
        {
            ResponseInfoModel json = new ResponseInfoModel()
            {
                Success = 1, Result = new object()
            };

            try
            {
                var publicity = _publicityCategoryService.Get(a => a.PublicityCategoryName == input.PublicityCateName);
                if (publicity == null)
                {
                    json.Result = new ListInfo()
                    {
                        List = new object[] { }
                    };
                    return(json);
                }
                else
                {
                    GetPublicityShowListInput newInput = new GetPublicityShowListInput()
                    {
                        PublicityTypesID = input.PublicityTypesID,
                        PublicityCateID  = publicity.ID,
                        Top = input.Top
                    };
                    var outputList = _PublicityContentService.GetShowList(newInput);
                    json.Result = new ListInfo()
                    {
                        List = outputList
                    };
                }
            }
            catch (Exception e)
            {
                DisposeUserFriendlyException(e, ref json, "api/publicity/showListByName", LocalizationConst.QueryFail);
            }
            return(json);
        }