コード例 #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>
        /// Data handling method to search for WatchList entities based on search criteria.
        /// </summary>
        /// <param name="searchCriteria">The search criteria object containing all required criteria info.</param>
        /// <param name="watchListId">Id of particular watchlist entity that has to be fetched. Pass 0 if not applicable.</param>
        /// <returns>List of WatchListEntity.</returns>
        public IList<WatchListEntity> SearchWatchList(GridSearchCriteriaEntity searchCriteria, int watchListId)
        {
            var watchList = new List<WatchListEntity>();

            try
            {
                using (DbCommand cmd =
                                Database.GetStoredProcCommand(DataAccess.StoredProcedure.Dbo.WATCH_LIST_SEARCH))
                {
                    cmd.Connection = Database.CreateConnection();
                    cmd.Connection.Open();

                    Database.AddInParameter(cmd, DataAccess.Params.WATCH_LIST_ID, DbType.Int32,
                                                SqlUtil.ParameterValue(watchListId));

                    Database.AddInParameter(cmd, DataAccess.Params.START_ROW_INDEX, DbType.Int32,
                                                SqlUtil.ParameterValue(searchCriteria.StartRowIndex));

                    Database.AddInParameter(cmd, DataAccess.Params.MAXIMUM_ROWS, DbType.Int32,
                                                SqlUtil.ParameterValue(searchCriteria.MaximumRows));

                    Database.AddInParameter(cmd, DataAccess.Params.SORT_COLUMN, DbType.String,
                                                SqlUtil.ParameterValue(searchCriteria.SortColumn));

                    Database.AddInParameter(cmd, DataAccess.Params.SORT_ASCENDING, DbType.Boolean,
                                                SqlUtil.ParameterValue(searchCriteria.SortAscending));

                    Database.AddInParameter(cmd, DataAccess.Params.SEARCH_CRITERIA, DbType.Xml,
                                                SqlUtil.ParameterValue(searchCriteria.SearchCriteria));

                    Database.AddInParameter(cmd, DataAccess.Params.TEXT_SEARCH_KEY, DbType.String,
                                                SqlUtil.ParameterValue(searchCriteria.TextSearchKey));

                    Database.AddInParameter(cmd, DataAccess.Params.SEARCH_AGAINST, DbType.Boolean,
                                                SqlUtil.ParameterValue(searchCriteria.SearchAgainst));

                    Database.AddInParameter(cmd, DataAccess.Params.SEARCH_WITH_OR, DbType.Boolean,
                                                SqlUtil.ParameterValue(searchCriteria.SearchWithOr));

                    Database.AddParameter(cmd, DataAccess.Params.RECORD_COUNT, DbType.Int32, ParameterDirection.InputOutput, null,
                                          DataRowVersion.Default, searchCriteria.RecordCount);

                    using (IDataReader dr = cmd.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            var watchListItem = new WatchListEntity();

                            watchListItem.Load(SqlUtil.SetValue(dr[DataAccess.Params.WATCH_LIST_ID], 0),
                                SqlUtil.SetValue(dr[DataAccess.Params.BSE_SYMBOL], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.NSE_SYMBOL], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.NAME], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.ALT_NAME_ONE], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.ALT_NAME_TWO], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.ALT_NAME_THREE], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.TEMP_NAME], string.Empty),
                                SqlUtil.SetValue(dr[DataAccess.Params.IS_ACTIVE], true),
                                SqlUtil.SetValue(dr[DataAccess.Params.ALERT_REQUIRED], true),
                                SqlUtil.SetValue(dr[DataAccess.Params.CREATED_ON], DateTime.MinValue),
                                SqlUtil.SetValue(dr[DataAccess.Params.MODIFIED_ON], DateTime.MinValue));

                            watchList.Add(watchListItem);
                        }
                    }

                    searchCriteria.RecordCount = SqlUtil.SetValue(cmd.Parameters["@" + DataAccess.Params.RECORD_COUNT], 0);
                }
            }
            catch (Exception exception)
            {
                watchList = null;
            }

            return watchList;
        }
コード例 #4
0
        /// <summary>
        /// Business method to search for WatchList entities based on search criteria.
        /// </summary>
        /// <param name="searchCriteria">The search criteria object containing all required criteria info.</param>
        /// <param name="watchListId">Id of particular watchlist entity that has to be fetched. Pass 0 if not applicable.</param>
        /// <returns>List of WatchListEntity.</returns>
        public IList<WatchListEntity> SearchWatchList(GridSearchCriteriaEntity searchCriteria, int watchListId)
        {
            IWatchListDataHandler watchListData = new WatchListDataHandler();

            return watchListData.SearchWatchList(searchCriteria, watchListId);
        }