Beispiel #1
0
        public enErrorCode AddNews(AddNewsRequestDTO dto)
        {
            enErrorCode enCode = enErrorCode.EXCEPTION;

            try
            {
                News n = new News()
                {
                    Title       = dto.Title.Trim(),
                    Category    = dto.Category.ToString(),
                    NewsContent = dto.NewsContent.Trim(),
                    IsEnable    = true,
                    CreateTime  = DateTime.Now
                };

                var dbSet  = _dbContext.Set <News>().Add(n);
                int result = _dbContext.SaveChanges();

                if (result == 1)
                {
                    enCode = enErrorCode.SUCCESS;
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            return(enCode);
        }
        public ActionResult AddNews(AddNewsRequestDTO dto)
        {
            string      url    = "api/News/AddNews";
            enErrorCode result = _apiAdaptor.Post <AddNewsRequestDTO, enErrorCode>(url, dto);

            return(RedirectToAction("BackEndIndex", "News"));
        }