Example #1
0
        public virtual ActionResult EditNewsTag(string btnId, string formId, NewsTagModel model)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsTag = _newsTagService.GetNewsTagById(model.Id);

            if (newsTag == null)
            {
                //No news tag found with the specified id
                return(RedirectToAction("List"));
            }

            if (ModelState.IsValid)
            {
                newsTag.Name = model.Name;
                _newsTagService.UpdateNewsTag(newsTag);


                ViewBag.RefreshPage = true;
                ViewBag.btnId       = btnId;
                ViewBag.formId      = formId;
                return(View(model));
            }

            //If we got this far, something failed, redisplay form
            return(View(model));
        }
        public IActionResult CreateNewsTag(NewsTagModel newsTagModel)
        {
            if (newsTagModel == null)
            {
                return(BadRequest("null"));
            }
            bool check = _newsTagLogic.CreateTagNews(newsTagModel);

            if (!check)
            {
                return(BadRequest("Cannot create a new tag of news"));
            }
            return(Ok("Success"));
        }
Example #3
0
        public bool CreateTagNews(NewsTagModel newsTagModel)
        {
            bool check = false;

            if (newsTagModel != null)
            {
                NewsTag newTag = new NewsTag()
                {
                    TagId  = newsTagModel.TagId,
                    NewsId = newsTagModel.NewsId,
                };
                _unitOfWork.GetRepository <NewsTag>().Insert(newTag);
                _unitOfWork.Commit();
                check = true;
            }
            return(check);
        }
Example #4
0
        //edit
        public virtual ActionResult EditNewsTag(int id)
        {
            if (!_permissionService.Authorize(StandardPermissionProvider.ManageNews))
            {
                return(AccessDeniedView());
            }

            var newsTag = _newsTagService.GetNewsTagById(id);

            if (newsTag == null)
            {
                //No news tag found with the specified id
                return(RedirectToAction("List"));
            }

            var model = new NewsTagModel
            {
                Id        = newsTag.Id,
                Name      = newsTag.Name,
                NewsCount = _newsTagService.GetNewsCount(newsTag.Id, 0)
            };

            return(View(model));
        }
 public static NewsTag ToEntity(this NewsTagModel model, NewsTag destination)
 {
     return(model.MapTo(destination));
 }
 public static NewsTag ToEntity(this NewsTagModel model)
 {
     return(model.MapTo <NewsTagModel, NewsTag>());
 }