public async Task <Unit> Handle(StartDeliveryCommand request, CancellationToken cancellationToken) { var loadingPlace = await loadingPlaceRepo .GetByConditionWithIncludeFirst(x => x.Id == request.LoadingPlaceId, y => y.PacksToDelivery); await ChangePacksStatusToSended(loadingPlace); loadingPlace.LoadingPlaceStatus = LoadingPlaceStatus.Sended; await loadingPlaceRepo.SaveAllAsync(); return(Unit.Value); }
public async Task <Unit> Handle(CompleteDeliveryCommand request, CancellationToken cancellationToken) { var loadingPlace = await loadingPlaceRepo .GetByConditionWithIncludeFirst(x => x.Id == request.LoadingPlaceId, y => y.PacksToDelivery); await ChangePacksStatusToDelivered(loadingPlace); ClearLoadedQuantityFromLoadingPlace(loadingPlace); await loadingPlaceRepo.SaveAllAsync(); return(Unit.Value); }
public async Task <Unit> Handle(LoadPackCommand request, CancellationToken cancellationToken) { var pack = await packToDeliveryRepo.GetByConditionFirst(x => x.Id == request.PackId); var loadingPlace = await loadingPlaceRepo.GetByConditionFirst(x => x.Id == request.LoadingPlaceId); ValidateLoadingPlaceAmountOfSpace(pack, loadingPlace); SetPackLoadingPlace(pack, loadingPlace); IncreaseLoadingPlaceLoadedQuantity(pack, loadingPlace); await loadingPlaceRepo.SaveAllAsync(); await bus.Publish(new ChangeOrderStatusEvent(pack.OrderId, OrderStatus.ReadyToSend)); return(Unit.Value); }
public async Task <Unit> Handle(UpdateLoadingPlaceCommand request, CancellationToken cancellationToken) { var loadingPlace = await loadingPlaceRepo.GetById(request.Id); CheckIfAmountOfSpaceIsGreaterThanLoadedQuantity(request, loadingPlace); mapper.Map(request, loadingPlace); try { await loadingPlaceRepo.SaveAllAsync(); } catch (ChangesNotSavedCorrectlyException) { return(Unit.Value); } return(Unit.Value); }
private async Task DeleteLoadingPlace(LoadingPlace loadingPlace) { loadingPlaceRepo.Delete(loadingPlace); await loadingPlaceRepo.SaveAllAsync(); }
private async Task AddLoadingPlace(LoadingPlace loadingPlace) { loadingPlaceRepo.Add(loadingPlace); await loadingPlaceRepo.SaveAllAsync(); }