Esempio n. 1
0
        public async Task <IHttpActionResult> Put(CMS_Content cmsContent)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var tempContent = UnitOfWork.CMS_ContentRepository.GetByID(cmsContent.Id);

            if (tempContent == null)
            {
                return(NotFound());
            }
            else
            {
                tempContent.Title      = cmsContent.Title;
                tempContent.Content    = cmsContent.Content;
                tempContent.Sequence   = cmsContent.Sequence;
                tempContent.Keywords   = cmsContent.Keywords;
                tempContent.UpdateTime = DateTimeOffset.Now;
                tempContent.UpdateBy   = User.Identity.GetUserName();

                UnitOfWork.CMS_ContentRepository.Update(tempContent);
                UnitOfWork.SaveChanges();
                return(Updated(tempContent));
            }
        }
Esempio n. 2
0
        public async Task <IHttpActionResult> Post(CMS_ContentInfoViewModel content)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            CMS_Content cmsContent = new CMS_Content()
            {
                Id         = Guid.NewGuid(),
                CreateTime = DateTimeOffset.Now,
                CreateBy   = User.Identity.GetUserName(),
                Title      = content.Title,
            };

            UnitOfWork.CMS_ContentRepository.Add(cmsContent);
            UnitOfWork.SaveChanges();
            return(Created(cmsContent));
        }
Esempio n. 3
0
        public static CMS_Content ToEntity(CMSContentModel model)
        {
            CMS_Content cms = new CMS_Content();

            cms.CategoryId  = model.CategoryId;
            cms.ColumnId    = model.ColumnId;
            cms.ContentText = model.ContentText;
            cms.Description = model.Description;
            cms.ID          = model.Id;
            cms.Img         = model.Img;
            cms.IsRelease   = model.IsRelease;
            cms.Keywords    = model.Keywords;
            cms.Orderby     = model.Orderby;
            cms.StateCode   = model.StateCode;
            cms.Title       = model.Title;
            cms.Time        = model.Time;
            cms.TopOrderby  = model.TopOrderby;
            return(cms);
        }