Example #1
0
        public ListDataResponse <AssetLocation> GetAssetsBySearch(SearchAsset search)
        {
            ListDataResponse <AssetLocation> response = new ListDataResponse <AssetLocation>();

            try
            {
                var result = _appContext.AssetLocations.Where(x => x.LocationId == search.LocationId &&
                                                              (x.Name1.ToLower().Contains(search.searchValue.ToLower()) || x.AssetRef.Contains(search.searchValue))).ToList();



                if (result.Count > 0)
                {
                    response.ListResult      = result;
                    response.IsSuccess       = true;
                    response.AffectedRecords = result.Count;
                    response.EndUserMessage  = "Get Asset Details Successfull";
                }
                else
                {
                    response.IsSuccess       = true;
                    response.AffectedRecords = 0;
                    response.EndUserMessage  = "No Asset Details Found";
                }
            }
            catch (Exception ex)
            {
                response.IsSuccess       = false;
                response.AffectedRecords = 0;
                response.EndUserMessage  = ex.InnerException == null ? ex.Message : ex.InnerException.Message;
                response.Exception       = ex;
            }

            return(response);
        }
Example #2
0
        public async Task <List <AssetSummary> > Handle(SearchAsset message, CancellationToken cancellationToken)
        {
            var query = from asset in context.Assets
                        join subcat in context.Categories on asset.CategoryId equals subcat.Id
                        join cat in context.Categories on subcat.ParentId equals cat.Id

                        from historicalStage in context.HistoricalStages
                        .Where(x => x.AssetId == asset.Id)
                        .OrderByDescending(x => x.Id)
                        .Take(1)
                        join stage in context.Stages on historicalStage.StageId equals stage.Id
                        orderby asset.Id descending
                        select new AssetSummary
            {
                AssetSubcategory        = subcat.Code,
                AssetCategory           = cat.Code,
                AssetId                 = asset.Id,
                AssetName               = asset.Name,
                EstimatedAmount         = historicalStage.EstimatedAmount,
                EstimatedAmountCurrency = historicalStage.EstimatedAmountCurrency,
                AssetIdentifier         = asset.Identifier,
                CurrentStage            = stage.Name
            };

            return(await query.ToListAsync(cancellationToken));
        }
Example #3
0
 public ListDataResponse <AssetLocation> GetAssetsBySearch(SearchAsset search)
 {
     return(_unitOfWork.Assets.GetAssetsBySearch(search));
 }