public async Task <CreateDetailsResponse> Handle(CreateDetailsRequest request, CancellationToken cancellationToken) { if (request.AuthenticationRole == "UserLaundry") { return(new CreateDetailsResponse() { Error = new ErrorModel(ErrorType.Unauthorized) }); } var query = new GetAllWarehauseDetailsQuery() { WarehauseId = request.WarehauseId, HotelLinenId = request.HotelLinenId }; var details = await this.queryExecutor.Execute(query); if (details != null) { return(new CreateDetailsResponse() { Error = new ErrorModel(ErrorType.Conflict) }); } var mappedDetails = this.mapper.Map <DataAccess.Entities.WarehauseDetail>(request); var command = new CreateWarehauseDetailCommand() { Parameter = mappedDetails }; var detailsFromDB = await this.commandExecutor.Execute(command); return(new CreateDetailsResponse() { Data = this.mapper.Map <Domain.Models.WarehauseDetail>(detailsFromDB) }); }
public async Task <GetAllDetailsResponse> Handle(GetAllDetailsRequest request, CancellationToken cancellationToken) { var query = new GetAllWarehauseDetailsQuery() { HotelLinenId = request.HotelLinenId, WarehauseId = request.WarehauseId, CompanyId = request.AuthenticationCompanyId }; var details = await this.queryExecutor.Execute(query); var mappedDetails = this.mapper.Map <List <WarehauseDetail> >(details); //if (mappedDetails == null) //{ // return new GetAllDetailsResponse() // { // Error = new Domain.ErrorHandling.ErrorModel(ErrorType.NotFound) // }; //} return(new GetAllDetailsResponse() { Data = mappedDetails }); }