Exemple #1
0
        public async Task <PlantLogTypeDtoResponse> Handle(GetPlantLogTypeByIdQuery request, CancellationToken cancellationToken)
        {
            var result = await dbContext.PlantLogTypes.FindAsync(request.Id);

            if (null == result)
            {
                var response = new PlantLogTypeDtoResponse();
                response.AddErrorMessage(nameof(request.Id), "No entity found");
                return(response);
            }
            return(new PlantLogTypeDtoResponse
            {
                Success = true,
                Data = PlantLogTypeDto.FromDao(result)
            });
        }
Exemple #2
0
        public async Task <PlantLogTypeDtosResponse> Handle(GetAllPlantLogTypesQuery request, CancellationToken cancellationToken)
        {
            var query = dbContext.PlantLogTypes.AsQueryable();

            if (!string.IsNullOrWhiteSpace(request.NameFilter))
            {
                query = query.Where(plt => plt.Name.Contains(request.NameFilter));
            }

            var results = await query.Select(plt => PlantLogTypeDto.FromDao(plt)).ToListAsync(cancellationToken);

            return(new PlantLogTypeDtosResponse
            {
                Success = true,
                Data = results,
            });
        }
Exemple #3
0
 public static PlantLogType FromCore(PlantLogTypeDto plantLogTypeDto)
 {
     return(new PlantLogType {
         Id = plantLogTypeDto.Id, Name = plantLogTypeDto.Name
     });
 }