public async Task <GarmentScrapSource> Handle(RemoveGarmentScrapSourceCommand request, CancellationToken cancellationToken) { var gscrapSource = _garmentScrapSourceRepository.Query.Where(o => o.Identity == request.Identity).Select(o => new GarmentScrapSource(o)).Single(); if (gscrapSource == null) { throw Validator.ErrorValidation(("Identity", "Invalid Id: " + request.Identity)); } gscrapSource.Remove(); await _garmentScrapSourceRepository.Update(gscrapSource); _storage.Save(); return(gscrapSource); }
public async Task <GarmentScrapSource> Handle(PlaceGarmentScrapSourceCommand request, CancellationToken cancellationToken) { GarmentScrapSource garmentScrapSource = new GarmentScrapSource( Guid.NewGuid(), request.Code, request.Name, request.Description ); await _garmentScrapSourceRepository.Update(garmentScrapSource); _storage.Save(); return(garmentScrapSource); }