public override async Task <GTIN> HandleCommand(CalculateCheckDigitGTINCommand request, CancellationToken cancellationToken) { var company = await companyQueries.GetByUserIdAsync(request.LoginSession.Id); if (company == null) { throw new BusinessException("Common.NoPermission"); } var gTIN = (await gTINService.CalculateCheckDigitAsync(request.Model)).ToInformation(); gTIN.Code = await gTINService.GetCodeGTINAsync(gTIN); return(gTIN); }
public override async Task <IEnumerable <Production> > HandleCommand(GetAllProductionCommand request, CancellationToken cancellationToken) { var company = await companyQueries.GetByUserIdAsync(request.LoginSession.Id); if (company == null) { throw new BusinessException("Common.NoPermission"); } var lst = (await productionQueries.GetAllAsync(company?.Id)).ToList(); foreach (var item in lst) { if (item.GTIN != null) { item.GTIN.Code = await gTINService.GetCodeGTINAsync(item.GTIN); } } return(lst); }
public override async Task <Production> HandleCommand(GetByIdProductionCommand request, CancellationToken cancellationToken) { var company = await companyQueries.GetByUserIdAsync(request.LoginSession.Id); if (company == null) { throw new BusinessException("Common.NoPermission"); } var rs = await productionQueries.GetByIdAsync(request.Model); if (rs == null) { throw new BusinessException("Production.NotExist"); } if (rs.GTIN != null) { rs.GTIN.Code = await gTINService.GetCodeGTINAsync(rs.GTIN); } return(rs); }
public override async Task <GTINInformation> HandleCommand(InsertOrUpdateGTINCommand request, CancellationToken cancellationToken) { var company = await companyQueries.GetByUserIdAsync(request.LoginSession.Id); if (company == null) { throw new BusinessException("Common.NoPermission"); } GTIN gTIN = (await gTINService.InsertOrUpdateGTINAsync(company.Id, request.Model, request.LoginSession)).ToInformation(); if (gTIN == null) { throw new BusinessException("Common.TaskFailed"); } var rs = gTIN.ToInformation(); rs.Code = await gTINService.GetCodeGTINAsync(gTIN); return(rs); }