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) }); }
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, }); }
public static PlantLogType FromCore(PlantLogTypeDto plantLogTypeDto) { return(new PlantLogType { Id = plantLogTypeDto.Id, Name = plantLogTypeDto.Name }); }