Ejemplo n.º 1
0
        public ActionResult NewsDetail(News news)
        {
            News origin = nr.Get(news.Id);

            if (origin == null)
            {
                origin            = new News();
                origin.Creator    = CurrentUser.Id;
                origin.CreateTime = DateTime.Now;
            }
            origin.Title          = news.Title;
            origin.CategoryId     = news.CategoryId;
            origin.PreviewContent = news.PreviewContent;
            origin.Content        = news.Content;
            origin.Author         = news.Author;
            origin.Source         = news.Source;
            if (origin.Id > 0)
            {
                nr.Update(origin);
            }
            else
            {
                nr.Create(origin);
            }
            return(RedirectToAction("News", new { id = origin.Id }));
        }
Ejemplo n.º 2
0
        public ActionResult Create(News news)
        {
            if (ModelState.IsValid)
            {
                news.Text       = HttpUtility.UrlDecode(news.Text, System.Text.Encoding.Default);
                news.CreateDate = DateTime.Now;
                news.EditDate   = DateTime.Now;
                news.EditUser   = User.Identity.Name;
                if (NewsRepository.Create(news))
                {
                    return(RedirectToAction("Index"));
                }
                else
                {
                    return(View(news));
                }
            }

            return(View(news));
        }
Ejemplo n.º 3
0
 public void Create(News entity)
 {
     NewsRepository.Create(entity);
 }
Ejemplo n.º 4
0
 public void Add(News entity)
 {
     _newsRepository.Create(entity);
 }
Ejemplo n.º 5
0
        public IActionResult Create(NewsViewModel model)
        {
            var result = _newsRepository.Create(model);

            return(RedirectToAction("Edit", new { id = result.Data }));
        }
Ejemplo n.º 6
0
        public static bool Create(News news)
        {
            INewsRepository newsRepo = new NewsRepository();

            return(newsRepo.Create(news));
        }