示例#1
0
        public void UpdateNews(tb_News newsModel)
        {
            _repository = new NewsRepository();
            _repository.UpdateNews(newsModel);

            //tb_News dbNews = _repository.GetSingle(d => d.News_Id == newsModel.News_Id);
            //dbNews = newsModel;
            //_repository.SaveChanges();
        }
        public ActionResult News_Create([DataSourceRequest] DataSourceRequest request, NewsModel model)
        {
            if (model != null && ModelState.IsValid)
            {
                tb_News modelNew = new tb_News();
                AutoMapper.Mapper.CreateMap<NewsModel, tb_News>();
                modelNew = AutoMapper.Mapper.Map(model, modelNew);
                modelNew.Posted_Date = DateTime.Now;
                modelNew.Created_By = 1;
                modelNew.Created_Date = DateTime.Now;
                modelNew.Modify_By = 1;
                modelNew.Modify_Date = DateTime.Now;
                _newsBal.AddNews(modelNew);
            }

            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        }
        public ActionResult News_Destroy([DataSourceRequest] DataSourceRequest request, NewsModel model)
        {
            if (model != null)
            {
                tb_News modelNew = new tb_News();
                AutoMapper.Mapper.CreateMap<NewsModel, tb_News>();
                modelNew = AutoMapper.Mapper.Map(model, modelNew);
                _newsBal.UpdateNews(modelNew);
                //int empId = model.Emp_Id;
                _newsBal.DeleteNews(modelNew.News_Id);
            }

            return Json(new[] { model }.ToDataSourceResult(request, ModelState));
        }
示例#4
0
        public bool AddNews(tb_News news)
        {
            _repository = new NewsRepository();

            return _repository.AddNews(news);
        }