public void Put(int id, Route b) { b.route_id = id; if (!db.UpdateRoute(b)) { throw new HttpResponseException(HttpStatusCode.NotFound); } }
public ActionResult Edit(int id, Route route) { try { routeRepository.UpdateRoute(route); return(RedirectToAction("Index")); } catch { return(View()); } }
public async Task <Route> UpdateRoute(Route routeToUpdate, CancellationToken cancellationToken) { try { Route route = await _routeRepository.UpdateRoute(routeToUpdate, cancellationToken); return(route); } catch (DBConcurrencyException e) { throw new ConcurrentAccessException("This route has been edited by another user", e); } }
private async void btnSave_Click(object sender, RoutedEventArgs e) { try { View.Region = null; RouteRepository r = new RouteRepository(); if (View.ID == 0) { await r.AddRoute(View); } else { await r.UpdateRoute(View); } Frame.GoBack(); } catch (AggregateException ex) { string errorMsg = ""; foreach (var exception in ex.InnerExceptions) { errorMsg += Environment.NewLine + exception.Message; } ProfessorOak.ShowMessage("One or more exceptions have occured:", errorMsg); } catch (ApiException apiEx) { var sbuilder = new StringBuilder(); //sbuilder.AppendLine(string.Format("HTTP Status Code: {0}", apiEx.StatusCode.ToString())); sbuilder.AppendLine("Errors:"); foreach (var error in apiEx.Errors) { sbuilder.AppendLine("-" + error); } ProfessorOak.ShowMessage("There was a problem saving the Route:", sbuilder.ToString()); } catch (Exception ex) { if (ex.InnerException.Message.Contains("Connection with the server")) { ProfessorOak.ShowMessage("Error", "No connection with the server"); } else { ProfessorOak.ShowMessage("Error", "Could not complete operation"); } } }
public void UpdateRoute(Route route) { rep.UpdateRoute(route); }