示例#1
0
        public IActionResult Details(string id)
        {
            var entity = _newsData.Get(id);

            if (entity == null)
            {
                return(RedirectToAction("Index"));
            }

            var model = new NewsDocViewModel();

            model.Id   = entity._id;
            model.Main = entity.lead_paragraph;
            model.Type = entity.newsType;

            return(View(model));
        }
示例#2
0
        public IActionResult Create(NewsDocViewModel doc)
        {
            if (ModelState.IsValid)
            {
                var newsDoc = new NewsDoc
                {
                    lead_paragraph = doc.Main,
                    newsType       = doc.Type
                };

                _newsData.Add(newsDoc);

                doc.Id = newsDoc._id;
                return(RedirectToAction("Details", new { id = newsDoc._id }));
            }

            return(View());
        }