public async Task <Dal.Entities.Supplier> UpdateSupplier(Dal.Entities.Supplier supplier) { Guard.Argument(supplier, nameof(supplier)).NotNull(); await ValidateSupplier(supplier); await using var transaction = await _unitOfWork.GetTransaction(); try { var currentSupplier = await GetSupplierById(supplier.Id); supplier.TrackerCode = currentSupplier.TrackerCode; var mapper = ServiceMapper.GetMapper(); mapper.Map(supplier, currentSupplier); await _unitOfWork.SaveChanges(); var savedSupplier = await GetSupplierById(supplier.Id); await _trackerApiService.UpdateCustomerStatus(new UpdateCustomerRequest() { Active = supplier.Active ? "1" : "0", CustomerCode = savedSupplier.TrackerCode, StatusDate = DateTime.Now, StatusReason = "Update the supplier" }); await transaction.CommitAsync(); } catch (TrackingApiException ex) { await transaction.RollbackAsync(); throw new ServiceException(new ErrorMessage[] { new ErrorMessage() { Code = string.Empty, Message = $"Unable to create a supplier in tracker side" } }); } catch { await transaction.RollbackAsync(); throw; } return(await GetSupplierById(supplier.Id)); }
public async Task Test_Update_Customer() { var trackingApiService = new TrackerApiService(true); var response = await trackingApiService.UpdateCustomerStatus(new UpdateCustomerRequest() { CustomerCode = "T001", StatusDate = System.DateTime.Now, StatusReason = "PAYMENT ISSUES", Active = "0" }); Assert.IsTrue(response.IsSuccess.Equals("1")); }