public ActionResult SharedContentDelete(string deleteId) { SharedContents sharedContents = new SharedContents(); switch (sharedContents.Delete(deleteId)) { case 0: ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyDeleted); break; case 2: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); break; case 3: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemUsedSomewhereElse); break; default: ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError); break; } return(RedirectToAction("SharedContent")); }
public bool EqualsShared(Item otherItem) { if (otherItem == null) { return(false); } return(SharedContents.Equals(otherItem.SharedContents)); }
public List <SelectListItem> GetSelectItemList() { List <SelectListItem> result = new List <SelectListItem>(); SharedContents sharedContents = new SharedContents(); result.AddRange(sharedContents.GetAllSharedContentsAsSelectListItems()); return(result); }
public ActionResult SharedContent(BackEndSharedContentList backEndSharedContentList) { SharedContents sharedContents = new SharedContents(); backEndSharedContentList.SharedContentList = sharedContents.GetSharedContents(backEndSharedContentList.SharedContentCode, backEndSharedContentList.IsActive); if (backEndSharedContentList.SharedContentList.IsNull() || backEndSharedContentList.SharedContentList.Count == 0) { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.NoDataFound); } return(View(backEndSharedContentList)); }
public bool IsFileUsed(string filePath) { bool result = false; SharedContents sharedContents = new SharedContents(); if (sharedContents.IsNotNull()) { result = sharedContents.IsFileUsed(filePath); } return(result); }
public string GetContent(HtmlHelper htmlHelper, FrontEndCmsPage model, string id) { string result = string.Empty; SharedContent sharedContent = new SharedContents().GetSharedContent(id, model.LanguageCode, true); if (sharedContent.IsNotNull()) { //include any extra modules, excluding {$Content} and other {$SharedContent-...} to avoid recursion string controllerAction; string[] controllerActionArray; bool isModuleFound; foreach (string sharedContentPart in ExtensionsHelper.GetHtmlCodeParts(sharedContent.HtmlCode)) { isModuleFound = false; foreach (IModuleConnector moduleConnector in ModuleConnectorsHelper.GetModuleConnectors()) { foreach (SelectListItem module in moduleConnector.GetSelectItemList()) { if (!sharedContentPart.StartsWith("{$SharedContent") && sharedContentPart.ToLower() == module.Value.ToLower()) { isModuleFound = true; controllerAction = sharedContentPart.Substring(2, sharedContentPart.Length - 3); controllerActionArray = controllerAction.Split('-'); result += moduleConnector.GetContent(htmlHelper, model, controllerActionArray[1]); } } } if (!isModuleFound) { if (sharedContentPart != "{$Content}" && !sharedContentPart.StartsWith("{$SharedContent") && sharedContentPart.StartsWith("{$") && sharedContentPart.EndsWith("}") && sharedContentPart.Contains('-')) { controllerAction = sharedContentPart.Substring(2, sharedContentPart.Length - 3); controllerActionArray = controllerAction.Split('-'); result += htmlHelper.Action(controllerActionArray[1], "FrontEnd" + controllerActionArray[0], model).ToString(); } else { result += sharedContentPart; } } } } return(result); }
public Item(Relation relation, ItemContents sharedContents) { OwnerRelation = relation; if (sharedContents != null) { SharedContents = sharedContents; } else { SharedContents = new ItemContents(); } _parent = null; Daughter = null; _next = null; _prev = null; SharedContents.AddItemRelation(relation.Name, this); }
public Item GetItemAs(string relationName) { return(SharedContents.GetItemRelation(relationName)); }
public ActionResult SharedContentAddEdit(BackEndSharedContentAddEdit backEndSharedContent) { if (ModelState.IsValidOrRefresh()) { SharedContents sharedContents = new SharedContents(); int? result; bool isLoopSuccessful = true; foreach (BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages in backEndSharedContent.SharedContentLanguages) { result = sharedContents.AddEdit(backEndSharedContent.SharedContentCode, backEndSharedContent.NewSharedContentCode, backEndSharedContentLanguages.LanguageCode, backEndSharedContent.IsActive, backEndSharedContentLanguages.HtmlCode); switch (result) { case 0: //success break; case 2: isLoopSuccessful = false; ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); ViewData.IsFormVisible(false); break; case 3: isLoopSuccessful = false; ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings_SharedContent.SharedContentCodeAlreadyExists); break; default: isLoopSuccessful = false; ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError); break; } if (!isLoopSuccessful) { break; } } if (isLoopSuccessful) { if (backEndSharedContent.SharedContentCode.IsEmptyOrWhiteSpace()) { ModelState.Clear(); backEndSharedContent = new BackEndSharedContentAddEdit(); BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages; List <Language> allActiveLanguages = new Languages().GetAllLanguages(isActive: true); foreach (Language language in allActiveLanguages) { backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit(); backEndSharedContentLanguages.LanguageCode = language.LanguageCode; backEndSharedContentLanguages.LanguageName = language.LanguageName; backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages); } ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyAdded); } else { ModelState.AddResult(ViewData, ModelStateResult.Success, Resources.Strings.ItemSuccessfullyEdited); } } } return(View(backEndSharedContent)); }
public ActionResult SharedContentAddEdit(string id) { BackEndSharedContentAddEdit backEndSharedContent = new BackEndSharedContentAddEdit(); SharedContents sharedContents = new SharedContents(); SharedContent sharedContent; BackEndSharedContentLanguagesAddEdit backEndSharedContentLanguages; List <Language> allActiveLanguages = new Languages().GetAllLanguages(isActive: true); if (allActiveLanguages.IsNotNull() && allActiveLanguages.Count > 0) { if (id.IsNotEmptyOrWhiteSpace()) { List <SharedContent> backEndSharedContentList = sharedContents.GetSharedContents(id); if (backEndSharedContentList.IsNotNull() && backEndSharedContentList.Count > 0) { backEndSharedContent.SharedContentCode = id; backEndSharedContent.NewSharedContentCode = id; backEndSharedContent.IsActive = backEndSharedContentList[0].IsActive; foreach (Language language in allActiveLanguages) { backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit(); backEndSharedContentLanguages.LanguageCode = language.LanguageCode; backEndSharedContentLanguages.LanguageName = language.LanguageName; sharedContent = sharedContents.GetSharedContent(id, language.LanguageCode); if (sharedContent.IsNotNull()) { backEndSharedContentLanguages.HtmlCode = sharedContent.HtmlCode; } backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages); } } else { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.ItemDoesNotExist); ViewData.IsFormVisible(false); } } else { foreach (Language language in allActiveLanguages) { backEndSharedContentLanguages = new BackEndSharedContentLanguagesAddEdit(); backEndSharedContentLanguages.LanguageCode = language.LanguageCode; backEndSharedContentLanguages.LanguageName = language.LanguageName; backEndSharedContent.SharedContentLanguages.Add(backEndSharedContentLanguages); } } } else { ModelState.AddResult(ViewData, ModelStateResult.Error, Resources.Strings.UnexpectedError); } return(View(backEndSharedContent)); }