public async Task <bool> AssignToTransporter(int shipmentId, int shipmentTransporterId, int customerId, string language) { var currentUser = await _authenticationService.GetUser(User.Identity.Name); if (currentUser.CustomerId != customerId) { throw new HttpResponseException(HttpStatusCode.InternalServerError, "Provided customer is not assigned to your account"); } language.ConvertLocaleStringToServerLanguage(); //// check if there is other shipment transporter assigned, and unassign it var assignedTransporters = await _shipmentService.GetAssignedTransporters(new FilterShipmentTransporter { ShipmentId = shipmentId, CustomerId = customerId, }); var transporterAssigned = assignedTransporters.FirstOrDefault(item => item.Assigned); if (transporterAssigned != null) { await _shipmentService.AssignToTransporter(currentUser.Id, true, shipmentId, transporterAssigned.Id); } // assign current tranporter return (await _shipmentService.AssignToTransporter(currentUser.Id, true, shipmentId, shipmentTransporterId)); }
public async Task Test_AssignTransporterCheckmark_Is_Ok() { try { var a = await _shipmentService.AssignToTransporter(1000, false, 60, 88); ; { Assert.IsTrue(true); return; } } catch (Exception ex) { Assert.IsFalse(true); } }