示例#1
0
        public ServiceResult <GetFirstTitleAndNotReadCountOM> GetFirstTitleAndNotReadCount()
        {
            var om = new ArticleComponent().GetFirstTitleAndNotReadCount(ArticleAccountType.FiiiPay, this.GetUser().Id, this.IsZH());

            return(new ServiceResult <GetFirstTitleAndNotReadCountOM>
            {
                Data = om
            });
        }
示例#2
0
        public ServiceResult <GetFirstTitleAndNotReadCountOM> GetFirstTitleAndNotReadCount()
        {
            var om = new ArticleComponent().GetFirstTitleAndNotReadCount(ArticleAccountType.FiiiPos, this.GetMerchantAccountId(), this.IsZH());

            return(new ServiceResult <GetFirstTitleAndNotReadCountOM>
            {
                Data = om
            });
        }
示例#3
0
        public ServiceResult <List <ArticleModel> > List(int pageIndex = 1, int pageSize = 10)
        {
            var result = new ServiceResult <List <ArticleModel> >();
            var list   = new ArticleComponent().List(pageSize, pageIndex, ArticleAccountType.FiiiPos, this.GetMerchantAccountId(), this.IsZH());

            result.Data = list.Select(a => new ArticleModel
            {
                Id        = a.Id,
                Timestamp = a.CreateTime.ToUnixTime().ToString(),
                Title     = a.Title,
                Read      = a.Read,
                Intro     = a.Intro,
                Type      = a.Type
            }).ToList();
            return(result);
        }
示例#4
0
        public ServiceResult <ArticleListOM> List(ArticleListIM im)
        {
            var list = new ArticleComponent().List(im.PageSize, im.PageIndex + 1, Entities.ArticleAccountType.FiiiPay, this.GetUser().Id, this.IsZH());

            return(new ServiceResult <ArticleListOM>
            {
                Data = new ArticleListOM
                {
                    List = list.Select(a => new ArticleListOMItem
                    {
                        Id = a.Id,
                        Intro = a.Intro,
                        Read = a.Read,
                        Timestamp = a.CreateTime.ToUnixTime().ToString(),
                        Title = a.Title,
                        Type = a.Type
                    }).ToList()
                }
            });
        }
示例#5
0
        public IHttpActionResult PostArticle(ArticleViewModel article)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }



            Article newArticle = new Article
            {
                Name = article.Name
            };

            db.Articles.Add(newArticle);

            List <ArticleComponent> articleComponents = new List <ArticleComponent>();

            foreach (var component in article.Components)
            {
                ArticleComponent articleComponent = new ArticleComponent();

                articleComponent.ArticleId       = newArticle.Id;
                articleComponent.ComponentAmount = component.ComponentAmount;
                articleComponent.ComponentId     = component.Id;


                articleComponents.Add(articleComponent);
            }

            db.ArticleComponent.AddRange(articleComponents);

            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = article.Name }, article));
        }