protected void MediaTypeChange_Click(object sender, System.EventArgs e) { var mewMediaTypeId = long.Parse(MediaTypes.SelectedValue); var newMediaType = MediaTypesMapper.GetDataModel().MediaTypes.FirstOrDefault(i => i.ID == mewMediaTypeId); if ((newMediaType != null) && (newMediaType.ID != selectedItem.MediaType.ID)) { selectedItem.MediaTypeID = newMediaType.ID; selectedItem.ShowInMenu = newMediaType.ShowInMenu; selectedItem.ShowInSearchResults = newMediaType.ShowInSearchResults; foreach (var mediaTypeField in newMediaType.Fields) { var foundField = selectedItem.Fields.SingleOrDefault(i => i.FieldCode == mediaTypeField.FieldCode); if (foundField != null) { foundField.MediaTypeField = mediaTypeField; continue; } var newField = new MediaDetailField(); newField.CopyFrom(mediaTypeField); newField.UseMediaTypeFieldFrontEndLayout = true; newField.DateCreated = DateTime.Now; newField.DateLastModified = DateTime.Now; selectedItem.Fields.Add(newField); } if (selectedItem.UseMediaTypeLayouts) { selectedItem.MainLayout = newMediaType.MainLayout; selectedItem.FeaturedLayout = newMediaType.FeaturedLayout; selectedItem.SummaryLayout = newMediaType.SummaryLayout; } foreach (var field in selectedItem.Fields) { if (field.MediaTypeField != null && field.MediaTypeField.MediaType != newMediaType) { field.MediaTypeField = null; } } var returnObj = MediaDetailsMapper.Update(selectedItem); if (returnObj.IsError) { BasePage.DisplayErrorMessage("Error", returnObj.Error); } else { var url = AdminBasePage.GetAdminUrl(selectedItem.MediaTypeID, selectedItem.MediaID); Response.Redirect(url); } } }
public override object GetValue() { if (Values.Value == "") { var field = GetField(); var jsonObjList = new List <JsonObj>(); foreach (var item in field.FieldAssociations) { var jsonObj = new JsonObj(); jsonObj.name = item.MediaDetail.Title; jsonObj.id = item.MediaDetail.ID; jsonObj.adminUrl = AdminBasePage.GetAdminUrl(item.MediaDetail, true); jsonObjList.Add(jsonObj); } var jsonString = StringHelper.ObjectToJson(jsonObjList); return(jsonString); } else { return(Values.Value); } }
protected void Edit_Click(object sender, EventArgs e) { var id = ((LinkButton)sender).CommandArgument; if (id != "") { var mediaDetail = MediaDetailsMapper.GetByID(long.Parse(id)); if (mediaDetail != null) { var url = AdminBasePage.GetAdminUrl(mediaDetail.MediaTypeID, mediaDetail.MediaID); Response.Redirect(url); } } }
/*protected void SearchItems_Click(object sender, EventArgs e) * { * if(selectedItem != null) * { * Bind(SearchText.Text.Trim()); * } * }*/ protected void ItemList_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.DataItem == null) { return; } var dataItem = (IMediaDetail)e.Row.DataItem; if (dataItem != null) { var editLink = (HyperLink)e.Row.FindControl("Edit"); if (editLink != null) { editLink.NavigateUrl = AdminBasePage.GetAdminUrl(dataItem.MediaTypeID, dataItem.MediaID); } } }