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");
         }
     }
 }
Ejemplo n.º 2
0
 public void AddRoute(Route route)
 {
     rep.AddRoute(route);
 }
        public IHttpActionResult Post(Route b)
        {
            var route = db.AddRoute(b);

            return(Created(Request.RequestUri + "/" + route.route_id, route));
        }