public async Task <GarmentScrapDestination> Handle(RemoveGarmentScrapDestinationCommand request, CancellationToken cancellationToken) { var gscrapDestination = _garmentScrapDestinationRepository.Query.Where(o => o.Identity == request.Identity).Select(o => new GarmentScrapDestination(o)).Single(); if (gscrapDestination == null) { throw Validator.ErrorValidation(("Identity", "Invalid Id: " + request.Identity)); } gscrapDestination.Remove(); await _garmentScrapDestinationRepository.Update(gscrapDestination); _storage.Save(); return(gscrapDestination); }
public async Task <GarmentScrapDestination> Handle(PlaceGarmentScrapDestinationCommand request, CancellationToken cancellationToken) { GarmentScrapDestination garmentScrapDestination = new GarmentScrapDestination( Guid.NewGuid(), request.Code, request.Name, request.Description ); await _garmentScrapDestinationRepository.Update(garmentScrapDestination); _storage.Save(); return(garmentScrapDestination); }