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)); }
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")); }
public ActionResult Add() { var model = new NewsSyndicationItemViewModel { AddForCommunityPortal = PortalTypeValue == PortalTypeContract.Community, AddForResearchPortal = PortalTypeValue == PortalTypeContract.Research, }; return(View("AddNews", model)); }
private CreateNewsSyndicationItemContract CreateSyndicationItem(NewsSyndicationItemViewModel model, PortalTypeContract portalType) { return(new CreateNewsSyndicationItemContract { Title = model.Title, ItemType = NewsTypeEnumContract.Combined, Text = model.Content, Url = model.Url, PortalType = portalType, }); }