コード例 #1
0
ファイル: TestController.cs プロジェクト: omprsingh/CashCow
        public JsonResult test([FromJson] GridContext gridContext)
        {
            IWatchListBusiness iWatchListBusiness = new WatchListBusiness();
            var searchCriteria = new GridSearchCriteriaEntity();

            var watchListEntities = iWatchListBusiness.SearchWatchList(searchCriteria, 0);
            var watchListModels = watchListEntities.Select(x => WatchListModel.ConvertWatchListEntityToModel(x)).ToList();

            watchListModels.RemoveAt(3);

            var gridModel = this.GetGridModel(watchListModels, searchCriteria.RecordCount);

            return Json(gridModel, JsonRequestBehavior.AllowGet);
        }
コード例 #2
0
ファイル: TestController.cs プロジェクト: omprsingh/CashCow
        public ActionResult Index()
        {
            IWatchListBusiness iWatchListBusiness = new WatchListBusiness();
            var searchCriteria = new GridSearchCriteriaEntity();

            var watchListEntities = iWatchListBusiness.SearchWatchList(searchCriteria, 0);
            var watchListModels = watchListEntities.Select(x => WatchListModel.ConvertWatchListEntityToModel(x)).ToList();

            //watchListModels.Clear();

            var gridModel = this.GetGridModel(watchListModels, searchCriteria.RecordCount);

            ViewData["gridModel"] = gridModel;

            return View();
        }
コード例 #3
0
        /// <summary>
        /// Method to fetch watch list entity model based on watch list ID.
        /// </summary>
        /// <param name="watchListId">Id of watch list entity to be fetched.</param>
        /// <returns>Watch list model corresponding to the model.</returns>
        private WatchListModel GetWatchListEntityModel(int watchListId)
        {
            IWatchListBusiness iWatchListBusiness = new WatchListBusiness();

            var watchListEntities = iWatchListBusiness.SearchWatchList(new GridSearchCriteriaEntity(), watchListId);
            return WatchListModel.ConvertWatchListEntityToModel(watchListEntities[0]);
        }
コード例 #4
0
        /// <summary>
        /// Method to return GridModel for watchlist grid.
        /// </summary>
        /// <param name="gridContext">The grid context containing search, sort and paging info.</param>
        /// <returns>The grid model required for grid construction.</returns>
        private GridModel CreateWatchListGridModel(GridContext gridContext)
        {
            var gridModelBuilder = new GridModelBuilder();

            // Create grid search criteria from the grid context and retrieve list of watch list entities from the DB.
            var gridSearchCriteria = this.CreateGridSearchCriteriaEntity(gridContext);

            IWatchListBusiness iWatchListBusiness = new WatchListBusiness();

            var watchListEntities = iWatchListBusiness.SearchWatchList(gridSearchCriteria, 0);
            var watchListModels = watchListEntities.Select(WatchListModel.ConvertWatchListEntityToModel).ToList();

            // Grid context is already available. Just set the number of records in it.
            gridContext.GridPager.TotalRecord = gridSearchCriteria.RecordCount;

            // Create list of columns in the grid.
            var columns = new List<GridColumnModel>
                              {
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "Name",
                                                               Label = "Name"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "BseSymbol",
                                                               Label = "BSE Symbol"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "NseSymbol",
                                                               Label = "NSE Symbol"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "AltNameOne",
                                                               Label = "Alt Name One"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "AltNameTwo",
                                                               Label = "Alt Name Two"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "AltNameThree",
                                                               Label = "Alt Name Three"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "TempName",
                                                               Label = "Temp Name"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               ColumnType = GridColumnType.Link,
                                                               Label = "Is Active?",
                                                               SortColumnName = "IsActive"
                                                           },
                                          Links = watchListModels.Select(x => new List<GridLinkModel>
                                                                                  {
                                                                                      new GridLinkModel
                                                                                          {
                                                                                              Action = "WatchList/ChangeActiveStatus/" + x.WatchListID,
                                                                                              Behaviour = GridActionBehaviour.PostSilent,
                                                                                              ImagePath = ConfigHelper.GetBooleanImage(x.IsActive)
                                                                                          }
                                                                                  }).ToList()
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               ColumnType = GridColumnType.Link,
                                                               Label = "Is Alert Required?",
                                                               SortColumnName = "AlertRequired"
                                                           },
                                          Links = watchListModels.Select(x => new List<GridLinkModel>
                                                                                  {
                                                                                      new GridLinkModel
                                                                                          {
                                                                                              Action = "WatchList/ChangeAlertStatus/" + x.WatchListID,
                                                                                              Behaviour = GridActionBehaviour.PostSilent,
                                                                                              ImagePath = ConfigHelper.GetBooleanImage(x.AlertRequired)
                                                                                          }
                                                                                  }).ToList()
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "ModifiedOn",
                                                               Label = "Modified On"
                                                           }
                                      },
                                  new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               BindingColumnName = "CreatedOn",
                                                               Label = "Created On"
                                                           }
                                      },
                                      new GridColumnModel
                                      {
                                          HeaderCell = new GridHeaderCellModel
                                                           {
                                                               ColumnType = GridColumnType.Link
                                                           },
                                          Links = watchListModels.Select(x => new List<GridLinkModel>
                                                                                  {
                                                                                      new GridLinkModel
                                                                                          {
                                                                                              Action = "WatchList/EditWatchList/" + x.WatchListID,
                                                                                              Behaviour = GridActionBehaviour.Popup,
                                                                                              Text = "Edit"
                                                                                          },
                                                                                      new GridLinkModel
                                                                                          {
                                                                                              Action = "WatchList/DeleteWatchList/" + x.WatchListID,
                                                                                              Behaviour = GridActionBehaviour.PostSilent,
                                                                                              Text = "Delete"
                                                                                          }
                                                                                  }).ToList()
                                      }
                              };

            // Create grid model builder entity.
            var gridModelBuilderEntity = new GridModelBuilderEntity
            {
                Columns = columns,
                GridContext = gridContext
            };

            // Build the grid context to be returned.
            return gridModelBuilder.BuildGridModel(gridModelBuilderEntity, watchListModels, Url.Action(_DefaultGridAction));
        }