Exemplo n.º 1
0
 public ActionResult Create(NewsTableModel newsTableModel)
 {
     try
     {
         NewsTable newsTable = new NewsTable
         {
             ID           = newsTableModel.ID,
             NewsDate     = newsTableModel.NewsDate,
             NewsHeadLine = newsTableModel.NewsHeadLine,
             NewsText     = newsTableModel.NewsText
         };
         if (ModelState.IsValid)
         {
             if (newsTable.ID > 0)
             {
                 newsRepository.UpdateNews(newsTable);
             }
             else
             {
                 newsRepository.InsertNews(newsTable);
             }
         }
         else
         {
             return(View(newsTableModel));
         }
         return(RedirectToAction("Index"));
     }
     catch (Exception)
     {
         return(View(newsTableModel));
     }
 }
Exemplo n.º 2
0
        public ActionResult Create(int id = 0)
        {
            NewsTable newsTable = new NewsTable();

            if (id > 0)
            {
                newsTable = newsRepository.GetNewsById(id);
            }
            ViewBag.Trade = StaticData.GetTrade();
            NewsTableModel newsTableModel = new NewsTableModel
            {
                ID           = newsTable.ID,
                NewsDate     = newsTable.NewsDate,
                NewsHeadLine = newsTable.NewsHeadLine,
                NewsText     = newsTable.NewsText
            };

            return(View(newsTableModel));
        }