public static List <GridRowDto> MockPhotoGalleryPhotosGridRows(int rowCount) { List <GridRowDto> rows = new List <GridRowDto>(); for (int index = 1; index <= rowCount; index++) { GridRowDto row = new GridRowDto(); rows.Add(row); row.GridId = CmsRegister.PhotosGridId; List <DucValueDto> cells = new List <DucValueDto>(); row.Cells = cells; DucValueDto valueTitle = new DucValueDto { DucId = BlockRegister.PhotoGrid.Col_Title }; cells.Add(valueTitle); valueTitle.ValueText = string.Format("Photo No.{0} Title", index); DucValueDto valueAbstract = new DucValueDto { DucId = BlockRegister.PhotoGrid.Col_Abstract }; cells.Add(valueAbstract); valueAbstract.ValueText = string.Format("Photo No.{0} abstract", index); DucValueDto valueImage = new DucValueDto { DucId = BlockRegister.PhotoGrid.Col_Image }; cells.Add(valueImage); valueImage.ValueUrl = "http://placehold.it/460x230"; } return(rows); }
public static List <GridRowDto> MockRecipeDetailInstructionGridRows(int rowCount) { List <GridRowDto> rows = new List <GridRowDto>(); for (int index = 1; index <= rowCount; index++) { GridRowDto row = new GridRowDto(); rows.Add(row); row.GridId = CmsRegister.InstructionGridId; List <DucValueDto> cells = new List <DucValueDto>(); row.Cells = cells; DucValueDto valueOrder = new DucValueDto { DucId = BlockRegister.RecipeInstructionGrid.Col_Sortorder, ValueInt = index }; cells.Add(valueOrder); DucValueDto valueDescription = new DucValueDto { DucId = BlockRegister.RecipeInstructionGrid.Col_Description }; valueDescription.ValueText = string.Format("recipe instruction {0}, exact instructions on how to make this recipe exact instructions on how to make this recipe. exact instructions on how to make this recipe", index); cells.Add(valueDescription); } return(rows); }
public static List <GridRowDto> MockRecipeDetailIngredientGridRows(int rowCount) { List <GridRowDto> rows = new List <GridRowDto>(); for (int index = 1; index <= rowCount; index++) { GridRowDto row = new GridRowDto(); rows.Add(row); row.GridId = CmsRegister.IngredientGridId; List <DucValueDto> cells = new List <DucValueDto>(); row.Cells = cells; DucValueDto valueOrder = new DucValueDto { DucId = BlockRegister.RecipeIngredientGrid.Col_Sortorder, ValueInt = index }; cells.Add(valueOrder); DucValueDto valueIngredientName = new DucValueDto { DucId = BlockRegister.RecipeIngredientGrid.Col_IngredientName, ValueText = string.Format("ingredient {0}, just samples", index) }; cells.Add(valueIngredientName); DucValueDto valueQuantity = new DucValueDto { DucId = BlockRegister.RecipeIngredientGrid.Col_Quantity, ValueText = index.ToString() }; cells.Add(valueQuantity); DucValueDto valueUnitOfMeasure = new DucValueDto { DucId = BlockRegister.RecipeIngredientGrid.Col_UnitOfMeasure, ValueText = "spoons" }; cells.Add(valueUnitOfMeasure); } return(rows); }
public IFacadeUpdateResult <GridRowData> SaveGridRow(GridRowDto row) { using (IUnitOfWork uow = UnitOfWorkFactory.Instance.Start(DataStoreResolver.CMSDataStoreKey)) { ReferenceFacade facade = new ReferenceFacade(uow); IFacadeUpdateResult <GridRowData> result = facade.SaveGridRow(GridRowConverter.ConvertToData(row)); return(result); } }
private string[] ConvertRow(GridDto grid, GridRowDto row) { List <string> values = new List <string>(); values.Add(row.Id.ToString()); foreach (GridColumnDto column in grid.Columns) { DucValueDto ducValue = row.Cells.SingleOrDefault(o => o.DucId.Equals(column.Id)); if (ducValue != null) { switch (column.ColumnType) { case DucTypes.SubTitle: case DucTypes.Text: case DucTypes.TextArea: values.Add(ducValue.ValueText); break; case DucTypes.Html: case DucTypes.HtmlArea: values.Add(ducValue.ValueHtml); break; case DucTypes.Integer: values.Add(ducValue.ValueInt.HasValue ? ducValue.ValueInt.Value.ToString() : string.Empty); break; case DucTypes.Image: values.Add(ducValue.ValueUrl); values.Add(ducValue.ValueText); break; case DucTypes.Hyperlink: values.Add(ducValue.ValueUrl); values.Add(ducValue.ValueText); break; case DucTypes.Datetime: break; default: break; } } } return(values.ToArray()); }
public ActionResult EditGridRow(int referenceId, int jqGridID) { ReferenceInfoDto reference = GetReference(referenceId); GridDto grid = GetGrid(reference, jqGridID); List <GridRowDto> gridRows = reference.GridRows.Where(o => object.Equals(o.GridId, jqGridID)).ToList(); JQGrid gridInstance = new JQGrid(); switch (gridInstance.AjaxCallBackMode) { case AjaxCallBackMode.EditRow: bool isValidEdit = ValidateInput(); if (isValidEdit) { int rowId = Convert.ToInt32(Request.Form[BaseDto.FLD_Id]); GridRowDto row = gridRows.SingleOrDefault(r => r.Id.Equals(rowId)); foreach (GridColumnDto column in grid.Columns) { DucValueDto cell = row.Cells.SingleOrDefault(o => o.DucId.Equals(column.Id)); if (cell != null) { CollectValues(cell, Request.Form, column.ColumnType, reference); } } IFacadeUpdateResult <GridRowData> result = Service.SaveGridRow(row); if (result.IsSuccessful) { GridRowDto savedRow = result.ToDto(new GridRowConverter()); gridRows.Remove(row); gridRows.Add(savedRow); } } break; case AjaxCallBackMode.AddRow: bool isValid = ValidateInput(); if (isValid) { GridRowDto newRow = new GridRowDto(); newRow.ReferenceId = referenceId; newRow.GridId = jqGridID; List <DucValueDto> cells = new List <DucValueDto>(); newRow.Cells = cells; foreach (GridColumnDto column in grid.Columns) { DucValueDto cell = new DucValueDto(); cell.DucId = column.Id; CollectValues(cell, Request.Form, column.ColumnType, reference); cells.Add(cell); } IFacadeUpdateResult <GridRowData> result = Service.SaveGridRow(newRow); if (result.IsSuccessful) { GridRowDto savedRow = result.ToDto(new GridRowConverter()); gridRows.Add(savedRow); } } break; case AjaxCallBackMode.DeleteRow: int deleteRowId = Convert.ToInt32(Request.Form[BaseDto.FLD_Id]); bool isDeleteSuccessful = Service.DeleteGridRow(deleteRowId); gridRows.Remove(gridRows.SingleOrDefault(o => o.Id.Equals(deleteRowId))); break; } return(ConvertToJson(grid, gridRows)); }