private async Task RemoveTrips(TripsActionModel actionView) { var client = await ApiTools.GetAuthenticatedClient(HttpContext); foreach (var actionViewTrip in actionView.Trips) { if (actionViewTrip.IsSelected) { await client.DeleteAsync($"{_configuration["Api"]}/api/trip/{actionViewTrip.Trip.TripId}"); } } }
public async Task <IActionResult> ModifyTrips(TripsActionModel actionView) { switch (actionView.Action) { case "removeTrips": await RemoveTrips(actionView); break; case "setVehicle": await SetVehicle(actionView); break; } return(RedirectToAction("Index")); }
private async Task SetVehicle(TripsActionModel actionView) { var client = await ApiTools.GetAuthenticatedClient(HttpContext); foreach (var actionViewTrip in actionView.Trips) { if (actionViewTrip.IsSelected) { var content = ApiTools.GetHttpContent(new Trip { TripId = actionViewTrip.Trip.TripId, Vehicle = new Vehicle { VehicleId = actionView.SelectedVehicleId } }); await client.PutAsync($"{_configuration["Api"]}/api/trip/setVehicle", content); } } }