Ejemplo n.º 1
0
        public ActionResult AddNews(News news)
        {
            var userId = User.Identity.GetUserId();

            news.Date = DateTime.Now;
            news.UserId = new Guid(userId);

            AddNewsResponse response = NewsService.AddNews(new AddNewsRequest { News = news });
            if (response.Status)
            {
                return RedirectToAction("News");
            }

            return View();
        }
Ejemplo n.º 2
0
        public ActionResult UpdateNews(News news)
        {
            if (ModelState.IsValid)
            {
                var userId = User.Identity.GetUserId();
                news.Date = DateTime.Now;
                news.UserId = new Guid(userId);

                UpdateNewsResponse response = NewsService.UpdateNews(new UpdateNewsRequest { News = news });
                if (response.Status)
                {
                    GetAllNewsResponse getAllNewsResponse = NewsService.GetAllNews(new GetAllNewsRequest { PageLimit = defaultPageSize, PageNumber = 1 });
                    return View("NewsManager", getAllNewsResponse.News.ToList());
                }
            }

            return View("EditNews", news);
        }