Пример #1
0
        public IActionResult Create(CreateNewsInputModel model)
        {
            var news = newsService.CreateNews(model);

            this.Db.News.Add(news);

            this.Db.SaveChanges();

            return(this.RedirectToPage("/Home/Index"));
        }
Пример #2
0
        public News CreateNews(CreateNewsInputModel model)
        {
            var news = new News
            {
                Id          = model.Id,
                Name        = model.Name,
                Content     = model.Description,
                PublishedOn = model.PublishedOn
            };

            if (news == null)
            {
                throw new ApplicationException("Invalid information provided");
            }
            return(news);
        }