Ejemplo n.º 1
0
 public void Update(MediaCate model)
 {
     var target = Find(model.ID);
     db.Attach<MediaCate>(target);
     target.CateName = model.CateName;
     target.PID = model.PID;
     target.Level = model.Level;
     target.Code = model.Code;
     target.OrderIndex = model.OrderIndex;
     db.Commit();
 }
Ejemplo n.º 2
0
 public void Create(MediaCate model)
 {
     db.Add<MediaCate>(model);
     db.Commit();
 }
Ejemplo n.º 3
0
 public void Delete(MediaCate model)
 {
     var target = Find(model.ID);
     db.Remove<MediaCate>(target);
     db.Commit();
 }
Ejemplo n.º 4
0
        private void GetPrevMediaGroup(List<LinkGroup> result, MediaCate media, QueryTerm queryTerm)
        {
            if (media.PID.HasValue)
            {
                var pMedia = MediaCateService.GetALL().Single(x => x.ID == media.PID);

                LinkGroup mediaGroup = new LinkGroup()
                {
                    Group = new LinkItem()
                    {
                        Name = pMedia.CateName,
                        Url = Url.Action("index", new
                        {
                            province = queryTerm.Province,
                            city = queryTerm.City,
                            mediacode = pMedia.ID,
                            formatcode = queryTerm.FormatCode,
                            ownercode = queryTerm.OwnerCode,
                            periodcode = queryTerm.PeriodCode,
                            authstatus = queryTerm.AuthStatus,
                            deadline = queryTerm.DeadLine,
                            price = queryTerm.Price,
                            order = queryTerm.Order,
                            descending = queryTerm.Descending,
                            page = 1
                        })
                    }
                };

                var mediaList = MediaCateService.GetALL()
                   .Where(x => x.PID == pMedia.ID).ToList();

                var mediaSelectList = mediaList.Select(x => new LinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = queryTerm.Province,
                        city = queryTerm.City,
                        mediacode = x.ID,
                        formatcode = queryTerm.FormatCode,
                        ownercode = queryTerm.OwnerCode,
                        periodcode = queryTerm.PeriodCode,
                        authstatus = queryTerm.AuthStatus,
                        deadline = queryTerm.DeadLine,
                        price = queryTerm.Price,
                        order = queryTerm.Order,
                        descending = queryTerm.Descending,
                        page = 1
                    })
                }).ToList();

                if (mediaSelectList.Any(x => x.ID == media.ID))
                {
                    mediaSelectList.Single(x => x.ID == media.ID).Selected = true;
                }

                mediaGroup.Items = mediaSelectList;

                result.Add(mediaGroup);

                GetPrevMediaGroup(result, pMedia, queryTerm);
            }
            else
            {
                LinkGroup mediaGroup = new LinkGroup()
                {
                    Group = new LinkItem()
                    {
                        Name = "媒体分类",
                        Url = Url.Action("index", new
                        {
                            province = queryTerm.Province,
                            city = queryTerm.City,
                            mediacode = 0,
                            formatcode = queryTerm.FormatCode,
                            ownercode = queryTerm.OwnerCode,
                            periodcode = queryTerm.PeriodCode,
                            authstatus = queryTerm.AuthStatus,
                            deadline = queryTerm.DeadLine,
                            price = queryTerm.Price,
                            order = queryTerm.Order,
                            descending = queryTerm.Descending,
                            page = 1
                        })
                    }
                };

                var mediaList = MediaCateService.GetALL()
                   .Where(x => x.PID.Equals(null)).ToList();

                var mediaSelectList = mediaList.Select(x => new LinkItem()
                {
                    ID = x.ID,
                    Name = x.CateName,
                    Url = Url.Action("index", new
                    {
                        province = queryTerm.Province,
                        city = queryTerm.City,
                        mediacode = x.ID,
                        formatcode = queryTerm.FormatCode,
                        ownercode = queryTerm.OwnerCode,
                        periodcode = queryTerm.PeriodCode,
                        authstatus = queryTerm.AuthStatus,
                        deadline = queryTerm.DeadLine,
                        price = queryTerm.Price,
                        order = queryTerm.Order,
                        descending = queryTerm.Descending,
                        page = 1
                    })
                }).ToList();

                if (mediaSelectList.Any(x => x.ID == media.ID))
                {
                    mediaSelectList.Single(x => x.ID == media.ID).Selected = true;
                }

                mediaGroup.Items = mediaSelectList;

                result.Add(mediaGroup);

            }
        }