public static Framework.Models.DataAccessLayerMessageOfInteger GetCountMessage <T>(IQueryable <T> _Query, int currentIndex, int pageSize, string logMessage) { //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString(), logMessage)); Framework.Models.DataAccessLayerMessageOfInteger _retMessage = new Framework.Models.DataAccessLayerMessageOfInteger(); try { int _retval = IQueryableHelper.Count( _Query , currentIndex , pageSize ); _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.Success; _retMessage.Result = _retval; } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.Fail; _retMessage.Result = 0; _retMessage.Message = ex.Message; //log.Error(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Failed.ToString(), logMessage), ex); } //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString(), logMessage)); return(_retMessage); }
public static async Task <Framework.Models.DataAccessLayerMessageOfBoolean> GetExistsMessageAsync <T>(IQueryable <T> _Query, int currentIndex, int pageSize, string logMessage) { //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString(), logMessage)); Framework.Models.DataAccessLayerMessageOfBoolean _retMessage = new Framework.Models.DataAccessLayerMessageOfBoolean(); try { bool _retval = await IQueryableHelper.AnyAsync( _Query , currentIndex , pageSize ); _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.Success; _retMessage.Result = _retval; } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.Fail; _retMessage.Result = false; _retMessage.Message = ex.Message; //log.Error(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Failed.ToString(), logMessage), ex); } //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString(), logMessage)); return(_retMessage); }
public static TMessage GetCollectionMessage <TMessage, TCollection, TItem>(IQueryable <TItem> _Query, int currentIndex, int pageSize, string logMessage) where TMessage : Framework.Models.DataAccessLayerMessageBase <TCollection>, new() where TCollection : List <TItem>, new() { //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Started.ToString(), logMessage)); TMessage _retMessage = new TMessage(); try { bool _Exists = IQueryableHelper.Any( _Query , currentIndex , pageSize ); if (_Exists) { IEnumerable <TItem> _retval; if (currentIndex == -1 || pageSize == -1) { _retval = _Query; } else { _retval = _Query.Skip(currentIndex).Take(pageSize); } _retMessage.QueryPagingResult = new Framework.Queries.QueryPagingResult(); _retMessage.QueryPagingResult.PageSize = pageSize; _retMessage.QueryPagingResult.RecordCountOfCurrentPage = _retval.Count(); _retMessage.DataAccessLayerMessageStatus = _retMessage.QueryPagingResult.RecordCountOfCurrentPage == 0 ? Framework.Models.DataAccessLayerMessageStatus.SuccessButNoResult : Framework.Models.DataAccessLayerMessageStatus.Success; _retMessage.QueryPagingResult.CurrentIndexOfStartRecord = currentIndex; _retMessage.QueryPagingResult.CountOfRecords = _Query.Count(); _retMessage.Result = new TCollection(); _retMessage.Result.AddRange(_retval); } else { _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.SuccessButNoResult; _retMessage.Result = null; } } catch (Exception ex) { _retMessage.DataAccessLayerMessageStatus = Framework.Models.DataAccessLayerMessageStatus.Fail; _retMessage.Result = null; _retMessage.Message = ex.Message; //log.Error(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Failed.ToString(), logMessage), ex); } //log.Info(string.Format("{0}: {1}", Framework.Models.LoggingOptions.Data_Access_Layer_Process_Ended.ToString(), logMessage)); return(_retMessage); }