private IEnumerable <LogModel> PagingCatCountry(CategoryCriteria criteria, int page, int size, out long rowsCount) { string valueName, valueCode; valueName = valueCode = criteria.Query != null?criteria.Query.ToLower() : ""; Expression <Func <CatCountryLog, bool> > countryEx = x => (x.NewObject.NameEn.ToLower().Contains(valueName) || x.NewObject.Code.ToLower().Contains(valueCode)) && (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) && (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null); var filterCountry = Builders <CatCountryLog> .Filter.Where(countryEx); var queryCurrencyResult = mongoContext.CatCountries.Find(filterCountry); rowsCount = queryCurrencyResult.CountDocuments(); var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel { Id = x.Id, UserUpdated = x.PropertyCommon.UserModified, Action = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType), DatetimeUpdated = x.PropertyCommon.DatetimeModified, PropertyChange = x.PropertyCommon.PropertyChange, ObjectId = x.NewObject.Id.ToString(), Name = x.NewObject.Code ?? x.NewObject.NameEn, Code = int.TryParse(x.NewObject?.Id.ToString(), out int n) == true ? null : x.NewObject?.Id.ToString() });
private IEnumerable <LogModel> PagingCatStage(CategoryCriteria criteria, int page, int size, out long rowsCount) { Expression <Func <CatStageLog, bool> > stageEx = x => x.NewObject.Code.Contains(criteria.Query ?? "") && x.NewObject.StageNameEn.Contains(criteria.Query ?? "") && (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) && (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null); var filterStage = Builders <CatStageLog> .Filter.Where(stageEx); var queryCurrencyResult = mongoContext.CatStages.Find(filterStage); rowsCount = queryCurrencyResult.CountDocuments(); var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel { Id = x.Id, UserUpdated = x.PropertyCommon.UserModified, Action = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType), DatetimeUpdated = x.PropertyCommon.DatetimeModified, PropertyChange = x.PropertyCommon.PropertyChange, ObjectId = x.NewObject.Id.ToString(), Name = x.NewObject.StageNameEn, Code = null }); return(data); }
private IEnumerable <LogModel> PagingCatPlace(CategoryCriteria criteria, int page, int size, out long rowsCount) { string type = string.Empty; switch (criteria.TableType) { case CategoryTable.Warehouse: type = CatPlaceConstant.Warehouse; break; case CategoryTable.PortIndex: type = CatPlaceConstant.Port; break; case CategoryTable.Province: type = CatPlaceConstant.Province; break; case CategoryTable.District: type = CatPlaceConstant.District; break; case CategoryTable.Ward: type = CatPlaceConstant.Ward; break; } Expression <Func <CatPlaceLog, bool> > placeEx = x => x.NewObject.Code.Contains(criteria.Query ?? "") && x.NewObject.NameEn.Contains(criteria.Query ?? "") && (x.PropertyCommon.DatetimeModified >= criteria.FromDate || criteria.FromDate == null) && (x.PropertyCommon.DatetimeModified <= criteria.ToDate || criteria.ToDate == null) && (x.NewObject.PlaceTypeId.Contains(type ?? "")); var filterPlace = Builders <CatPlaceLog> .Filter.Where(placeEx); var queryCurrencyResult = mongoContext.CatPlaces.Find(filterPlace); rowsCount = queryCurrencyResult.CountDocuments(); var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel { Id = x.Id, UserUpdated = x.PropertyCommon.UserModified, Action = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType), DatetimeUpdated = x.PropertyCommon.DatetimeModified, PropertyChange = x.PropertyCommon.PropertyChange, ObjectId = x.NewObject.Id.ToString(), Name = x.NewObject?.NameEn, Code = x.NewObject?.Code }); return(data); }
private IEnumerable <LogModel> PagingCatCurrencyExchange(CategoryCriteria criteria, int page, int size, out long rowsCount) { var filterCurrencyExchange = Builders <CatCurrencyExchangeLog> .Filter.Where(_ => true); var queryCurrencyResult = mongoContext.CatCurrencyExchanges.Find(filterCurrencyExchange); rowsCount = queryCurrencyResult.CountDocuments(); var data = queryCurrencyResult.Skip(page * size).Limit(size).ToList().Select(x => new LogModel { Id = x.Id, UserUpdated = x.PropertyCommon.UserModified, Action = ConvertAction.ConvertLinqAction(x.PropertyCommon.ActionType), DatetimeUpdated = x.PropertyCommon.DatetimeModified, PropertyChange = x.PropertyCommon.PropertyChange, ObjectId = x.NewObject.Id.ToString(), Name = x.NewObject.CurrencyFromId }); return(data); }