// DELETE: api/POIs/5 public PuntoDeInteres Delete(int id) { PuntoDeInteres poiEliminado = null; foreach (var POI in this.listaPois) { if (POI.id == id) { POI.fechaBaja = DateTime.Now; poiEliminado = POI; } ; } if (poiEliminado != null) { logs.Add(new LogAction { id = (logs.ToString().Length) + 1, fechaInicio = poiEliminado.fechaBaja, fechaFin = DateTime.Now, procesoEjecutado = "2 - Baja de POIs", nombreUsuario = "abc", result = "Ok", mensajeDeError = "" }); return(poiEliminado); } else { logs.Add(new LogAction { id = (logs.ToString().Length) + 1, fechaInicio = DateTime.Now, fechaFin = DateTime.Now, procesoEjecutado = "2 - Baja de POIs", nombreUsuario = "abc", result = "Error", mensajeDeError = "Critical Exception" }); throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent("An error occurred, please try again or contact the administrator."), ReasonPhrase = "Critical Exception" }); } }
private void ListarPuntosDeInteres() { PuntoDeInteres PuntoDeInteres = new PuntoDeInteres(); PuntoDeInteres.Provincia = new Provincia(); PuntoDeInteres.Provincia.ID = int.Parse(Request["idProvincia"].ToString()); Response.Write(PuntoDeInteres.ListToJson()); }
// GET: api/POIs/5 public PuntoDeInteres Get(int id) { PuntoDeInteres poiBuscado = null; /* * foreach (var POI in this.listaPois) * { * if (POI.id == id) * { * poiBuscado = POI; * }; * } * * if (poiBuscado != null) * { * * logs.Add(new LogAction { id = (logs.ToString().Length) + 1, fechaInicio = poiBuscado.fechaBaja, fechaFin = DateTime.Now, procesoEjecutado = "2 - Baja de POIs", nombreUsuario = "abc", result = "Ok", mensajeDeError = "" }); * return poiBuscado; * } * else * { * switch (manejoError) { * case 1: * //Se envía un mail al Usuario avisando el fallo. * EnvioDeMails mail = new EnvioDeMails(); * mail.enviarMail(new TimeSpan(DateTime.Now.Millisecond), 1); * break; * case 2: * //Se reintenta n veces el proceso. Si se ejecuta n veces en forma errónea queda en estado “error”. * break; * case 3: * //No se realiza ninguna acción. * break; * * }; * logs.Add(new LogAction { id = (logs.ToString().Length) + 1, fechaInicio = DateTime.Now, fechaFin = DateTime.Now, procesoEjecutado = "2 - Baja de POIs", nombreUsuario = "abc", result = "Error", mensajeDeError = "Critical Exception" }); * * throw new HttpResponseException(new HttpResponseMessage(HttpStatusCode.InternalServerError) * { * Content = new StringContent("An error occurred, please try again or contact the administrator."), * ReasonPhrase = "Critical Exception" * }); * } */ foreach (var POI in this.listaPois) { if (POI.id == id) { poiBuscado = POI; } ; } return(poiBuscado); }
private void EliminarPuntoDeInteres() { try { PuntoDeInteres PuntoDeInteres = new PuntoDeInteres(); PuntoDeInteres.ID = int.Parse(Request["idPuntoDeInteres"].ToString()); PuntoDeInteres.Erase(); Response.Write(""); } catch (Exception Error) { Response.Write(Error.Message); } }
private void AgregarPuntoDeInteres() { try { PuntoDeInteres PuntoDeInteres = new PuntoDeInteres(); PuntoDeInteres.Nombre = Request["TBNombrePI"].ToString(); PuntoDeInteres.Descripcion = Request["TBDescripcionPI"].ToString(); PuntoDeInteres.Provincia = new Provincia(); PuntoDeInteres.Provincia.ID = int.Parse(Request["IDProvincia"].ToString()); PuntoDeInteres.Add(); if (Request.Files["TBFotoPI"].ContentLength > 0) { PuntoDeInteres.SaveImage(Request.Files["TBFotoPI"]); } Response.Write(PuntoDeInteres.Find()); } catch (Exception Error) { Response.Write(Error.Message); } }