public ViewResult EditContent(int id) { ReferenceEditViewModel model = GetModel(id); model.PageTitle = string.Format("Page Content Edit: {0}", model.Instance.Name); return(View(model)); }
private ReferenceEditViewModel GetModel(int referenceId) { ReferenceInfoDto reference = GetReference(referenceId); ReferenceEditViewModel model = new ReferenceEditViewModel(reference); model.FolderTree = GetCurrentFolderTree(reference.FolderId); model.CurrentLanguage = CurrentLanguage; return(model); }
public ViewResult Edit(int id) { ReferenceEditViewModel model = GetModel(id); model.PageTitle = string.Format("Page Basic Edit: {0}", model.Instance.Name); if (model.Instance.EnableLocation) { // Get available Locations IGeneralService generalService = ServiceLocator.Current.GetInstance <IGeneralService>(); model.AvailableLocations = generalService.GetPublishedLocations(); } return(View(model)); }
public ActionResult Edit(int id, FormCollection formData) { // Collect data from FormCollection ReferenceInfoDto reference = GetReference(id); UpdateModel(reference, formData); if (ModelState.IsValid) { if (reference.EnableLocation) { int selectedLocationId; if (int.TryParse(formData["SelectedLocationId"], out selectedLocationId)) { reference.LocationId = selectedLocationId; } } IFacadeUpdateResult <ReferenceData> result; if (CurrentLanguage.Id == WebContext.Current.DefaultLanguage.Id) { result = Service.SaveReferenceBasic(reference); } else { result = Service.SaveReferenceBasic(reference, CurrentLanguage.Id); } if (result.IsSuccessful) { return(RedirectToAction(DetailAction, new { id = id })); } else { ProcUpdateResult(result.ValidationResult, result.Exception); } } ReferenceEditViewModel model = new ReferenceEditViewModel(reference); model.FolderTree = GetCurrentFolderTree(reference.FolderId); model.CurrentLanguage = CurrentLanguage; model.PageTitle = string.Format("Page Basic Edit: {0}", model.Instance.Name); if (model.Instance.EnableLocation) { // Get available Locations IGeneralService generalService = ServiceLocator.Current.GetInstance <IGeneralService>(); model.AvailableLocations = generalService.GetPublishedLocations(); } return(View(model)); }
public ActionResult EditContent(int id, FormCollection formData) { // Collect data from FormCollection ReferenceInfoDto reference = GetReference(id); if (ModelState.IsValid) { foreach (ZoneInfoDto zone in reference.Template.Zones) { foreach (SubitemInfoDto item in zone.Block.Subitems) { if (item.DucType != DucTypes.Grid) { // Loop for each Subitem DucValueDto subitemValue = null; if (reference.ValuesDic.ContainsKey(item.SubitemId)) { // Already has value for current Subitem subitemValue = reference.ValuesDic[item.SubitemId]; CollectValues(subitemValue, formData, item.DucType, reference); } else { // No value for current Subitem, add new value subitemValue = new DucValueDto(); subitemValue.DucId = item.SubitemId; CollectValues(subitemValue, formData, item.DucType, reference); bool isValid = ValidateValue(subitemValue, item.DucType); if (isValid) { reference.ValuesDic.Add(item.SubitemId, subitemValue); } } } } } IFacadeUpdateResult <ReferenceData> result; if (CurrentLanguage.Id == WebContext.Current.DefaultLanguage.Id) { result = Service.SaveReferenceValues(reference.ReferenceId, reference.ValuesDic); } else { result = Service.SaveReferenceValues(reference.ValuesDic, CurrentLanguage.Id); } if (result.IsSuccessful) { return(RedirectToAction(DetailAction, new { id = id })); } else { ProcUpdateResult(result.ValidationResult, result.Exception); } } ReferenceEditViewModel model = new ReferenceEditViewModel(reference); model.FolderTree = GetCurrentFolderTree(reference.FolderId); model.CurrentLanguage = CurrentLanguage; model.PageTitle = string.Format("Page Content Edit: {0}", model.Instance.Name); return(View(model)); }