示例#1
0
        public ActionResult Add(NewsSyndicationItemViewModel model)
        {
            if (ModelState.IsValid)
            {
                if (model.AddForCommunityPortal || model.AddForResearchPortal)
                {
                    var client = GetNewsClient();

                    if (model.AddForCommunityPortal)
                    {
                        client.CreateNewsSyndicationItem(CreateSyndicationItem(model, PortalTypeContract.Community));
                    }

                    if (model.AddForResearchPortal)
                    {
                        client.CreateNewsSyndicationItem(CreateSyndicationItem(model, PortalTypeContract.Research));
                    }

                    return(RedirectToAction("Index", "Home"));
                }

                ModelState.AddModelError(string.Empty, Localizer.Translate("CreateNewsForOnePortalError", "News"));
            }

            return(View("AddNews", model));
        }
示例#2
0
        public ActionResult Add(NewsSyndicationItemViewModel model)
        {
            var username = GetUserName();

            using (var client = GetMainServiceClient())
                client.CreateNewsSyndicationItem(model.Title, model.Content, model.Url, (NewsTypeContract)model.ItemType, username);

            return(RedirectToAction("Index", "Home"));
        }
示例#3
0
        public ActionResult Add()
        {
            var model = new NewsSyndicationItemViewModel
            {
                AddForCommunityPortal = PortalTypeValue == PortalTypeContract.Community,
                AddForResearchPortal  = PortalTypeValue == PortalTypeContract.Research,
            };

            return(View("AddNews", model));
        }
示例#4
0
 private CreateNewsSyndicationItemContract CreateSyndicationItem(NewsSyndicationItemViewModel model, PortalTypeContract portalType)
 {
     return(new CreateNewsSyndicationItemContract
     {
         Title = model.Title,
         ItemType = NewsTypeEnumContract.Combined,
         Text = model.Content,
         Url = model.Url,
         PortalType = portalType,
     });
 }