public async Task <IActionResult> Edit(int id, [Bind("Id,Direccion,Ciudad")] Localizacion localizacion) { if (id != localizacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(localizacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocalizacionExists(localizacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(localizacion)); }
public ResponseViewModel CreateLocationAll(List <CreateLocationViewModel> model) { ResponseViewModel reponse = new ResponseViewModel(); try { foreach (var lista in model) { Localizacion localization = new Localizacion { IdEvento = lista.IdEvento, Activo = "1", Comentario = lista.Comentario, Direccion = lista.Direccion, Latitud = lista.Latitud, Longitud = lista.Longitud }; _eventPlusContext.Localizacion.Add(localization); _eventPlusContext.SaveChanges(); } reponse.Type = "success"; reponse.Response = "El regitsro se creo exitosamente."; return(reponse); } catch (Exception ex) { reponse.Type = "error"; reponse.Response = "Error en el procedimiento. ---> " + ex.Message; return(reponse); } }
public ActionResult save(/*JuegoPRViewModel model*/) { if (string.IsNullOrEmpty(this.error)) { List <LocalizacionDetails> model = Newtonsoft.Json.JsonConvert.DeserializeObject <List <LocalizacionDetails> >(this.Contenido); foreach (var item in model) { Localizacion local = new Localizacion(item, db, this.usuarioId); new Repositorio <Localizacion>(db).Crear(local); } //model.UserId = new Guid(User.Identity.GetUserId()); //var respuestas = new Repositorio<Localizacion>(db).TraerTodos().Where(x => x.Pregunta.Id == model.PregId); //var respOk = respuestas.Where(p => p.Escorrecta == true).Select(x => x.Id).FirstOrDefault(); //var hist = new JuegoHistory(model, db); //new Repositorio<JuegoHistory>(db).Crear(hist); //var pelicula = new Repositorio<Pelicula>(db).Traer(Id); //return Json(new { Id = respOk, model = model }, JsonRequestBehavior.AllowGet); return(Json(new { resp = "ok" }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { error = this.error }, JsonRequestBehavior.AllowGet)); } }
public async Task <IActionResult> Edit(int id, [Bind("Id,FilaId,ProductoId")] Localizacion localizacion) { if (id != localizacion.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(localizacion); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocalizacionExists(localizacion.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["FilaId"] = new SelectList(_context.Fila, "Id", "Nombre", localizacion.FilaId); ViewData["ProductoId"] = new SelectList(_context.Producto, "Id", "Nombre", localizacion.ProductoId); return(View(localizacion)); }
public ActionResult DeleteConfirmed(int id) { Localizacion localizacion = db.Localizacion.Find(id); db.Localizacion.Remove(localizacion); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id_loc,Direccion,Telefono,email,Ubicacion,Observacion")] Localizacion localizacion) { if (ModelState.IsValid) { db.Entry(localizacion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(localizacion)); }
public ActionResult Edit([Bind(Include = "Id,Descripcion")] Localizacion localizacion) { if (ModelState.IsValid) { db.Entry(localizacion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(localizacion)); }
public ActionResult Create([Bind(Include = "Id_loc,Direccion,Telefono,email,Ubicacion,Observacion")] Localizacion localizacion) { if (ModelState.IsValid) { db.Localizacion.Add(localizacion); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(localizacion)); }
public ActionResult Create([Bind(Include = "Id,Descripcion")] Localizacion localizacion) { if (ModelState.IsValid) { db.Localizaciones.Add(localizacion); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(localizacion)); }
public async Task <IActionResult> Create([Bind("Id,Direccion,Ciudad")] Localizacion localizacion) { if (ModelState.IsValid) { _context.Add(localizacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(localizacion)); }
public BaseEntity BuildObject(Dictionary <string, object> row) { var localizacion = new Localizacion { idLocalizacion = GetStringValue(row, DB_COL_IDLOCALIZACION), cedula = GetStringValue(row, DB_COL_CEDULA), tipoLocalizacion = GetStringValue(row, DB_COL_TIPO), valor = GetStringValue(row, DB_COL_VALOR) }; return(localizacion); }
public async Task <IActionResult> Create([Bind("Id,FilaId,ProductoId")] Localizacion localizacion) { if (ModelState.IsValid) { _context.Add(localizacion); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["FilaId"] = new SelectList(_context.Fila, "Id", "Nombre", localizacion.FilaId); ViewData["ProductoId"] = new SelectList(_context.Producto, "Id", "Nombre", localizacion.ProductoId); return(View(localizacion)); }
// GET: Localizacions/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Localizacion localizacion = db.Localizacion.Find(id); if (localizacion == null) { return(HttpNotFound()); } return(View(localizacion)); }
void Start() { localizacion = gameObject.name.ToUpper(); if (localizacion == Localizacion.CORP.ToString()) { thisLocalizacion = Localizacion.CORP; } else if (localizacion == Localizacion.SHOP.ToString()) { thisLocalizacion = Localizacion.SHOP; } else if (localizacion == Localizacion.LAB.ToString()) { thisLocalizacion = Localizacion.LAB; } }
//#################################### //### Código para Localización GPS ### //#################################### //private void btnLocalizar_Click(object sender, EventArgs e) //{ // if (listCarros.SelectedItems.Count!=0) // { // //### Barra de Estado // this.Cursor = Cursors.WaitCursor; // toolStripProgressBar1.Style = ProgressBarStyle.Marquee; // toolStripStatusLabel1.Text = "Localizando..."; // //### Obtiene Coordenadas y Label de Cada Carro // try // { // LocalizacionGPS lgps = LocalizacionGPS.StartClient(); // Localizacion l1=Localizacion.FromString(lgps.Localizar_s(1)); // List<PointD> points = new List<PointD>(); // List<string> labels = new List<string>(); // for (int i = 0; i < listCarros.SelectedItems.Count; i++) // { // Localizacion l = Localizacion.FromString(lgps.Localizar_s((int)((DataRowView)listCarros.SelectedItems[i])["id_carro"])); // PointD p = new PointD(l.Longitud, l.Latitud); // p = Data.Util.TransformCoord(p);//new PointD(346145.539, 6288689.478); // points.Add(p); // labels.Add((string)((DataRowView)listCarros.SelectedItems[i])["nombre"]); // } // //### Dibujar Cada Carro // PlugData.ZoomToPointsPaint(points.ToArray(), labels.ToArray()); // } // catch (Exception ex) // { // Log.ShowAndLog(ex); // } // //### Terminar la Barra de Estado // this.Cursor = Cursors.Default; // toolStripProgressBar1.Style = ProgressBarStyle.Blocks; // toolStripStatusLabel1.Text = ""; // } // else // { // MessageBox.Show("Debe seleccionar carros para localizarlos.", "Sistema ZEUS"); // } //} private void btnLocalizar_Click(object sender, EventArgs e) { if (listCarros.SelectedItems.Count != 0) { //### Barra de Estado this.Cursor = Cursors.WaitCursor; toolStripProgressBar1.Style = ProgressBarStyle.Marquee; toolStripStatusLabel1.Text = "Localizando..."; //### Obtiene Coordenadas y Label de Cada Carro try { LocalizacionGPS lgps = LocalizacionGPS.StartClient(); Localizacion l1 = Localizacion.FromString(lgps.Localizar_s(1)); List <PointD> points = new List <PointD>(); List <string> labels = new List <string>(); for (int i = 0; i < listCarros.SelectedItems.Count; i++) { Localizacion l = Localizacion.FromString(lgps.Localizar_s((int)((DataRowView)listCarros.SelectedItems[i])["id_carro"])); PointD p = new PointD(l.Longitud, l.Latitud); //### LatLong 2 UTM //p = Data.Util.TransformCoord(p);//new PointD(346145.539, 6288689.478); points.Add(p); labels.Add((string)((DataRowView)listCarros.SelectedItems[i])["nombre"]); } //### Dibujar Cada Carro PlugData.ZoomToPointsPaint(points.ToArray(), labels.ToArray()); } catch (Exception ex) { Log.ShowAndLog(ex); } //### Terminar la Barra de Estado this.Cursor = Cursors.Default; toolStripProgressBar1.Style = ProgressBarStyle.Blocks; toolStripStatusLabel1.Text = ""; } else { MessageBox.Show("Debe seleccionar carros para localizarlos.", "Sistema ZEUS"); } }
// DELETE == public IHttpActionResult Delete(Localizacion localizacion) { try { var mngLocalizacion = new LocalizacionManager(); mngLocalizacion.Delete(localizacion); apiResp = new ApiResponse(); apiResp.Message = "Action was executed."; return(Ok(apiResp)); } catch (Exceptions.BussinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
private void Button_Click(object sender, RoutedEventArgs e) { var origen = new Localizacion(); var destino = new Localizacion(); origen = estaciones[Origen.SelectedIndex]; destino = estaciones[Destino.SelectedIndex]; Reserva = new Reserva(); Reserva.Ruta = new Rutas(); Reserva.Ruta.Origen = origen; Reserva.Ruta.Destino = destino; Reserva.Ruta.FechaInicio = (DateTime)FechaViaje.SelectedDate; BuscarViaje(Reserva); }
public void Create(Localizacion localizacion) { try { var l = crudLocalizacion.Retrieve <Localizacion>(localizacion); if (l != null) { throw new BussinessException(3); } crudLocalizacion.Create(localizacion); } catch (Exception ex) { ExceptionManager.GetInstance().Process(ex); } }
public Localizacion RetrieveById(Localizacion localizacion) { Localizacion l = null; try { l = crudLocalizacion.Retrieve <Localizacion>(localizacion); if (l == null) { throw new BussinessException(4); } } catch (Exception ex) { ExceptionManager.GetInstance().Process(ex); } return(l); }
// GET api/direcciones/ // Retrieve by id public IHttpActionResult Get(string cedula) { try { var mngLocalizacion = new LocalizacionManager(); var localizacion = new Localizacion { cedula = cedula }; localizacion = mngLocalizacion.RetrieveById(localizacion); apiResp = new ApiResponse(); apiResp.Data = localizacion; return(Ok(apiResp)); } catch (Exceptions.BussinessException bex) { return(InternalServerError(new Exception(bex.ExceptionId + "-" + bex.AppMessage.Message))); } }
public void XmlSerializarObjeto(string filepath) { IFormatter formatter = new SoapFormatter(); Localizacion ListDat = new Localizacion() { Estado = "Lima", Ciudad = "Lima Central", Pais = "Perú", Estacion = "Perú 1" }; /* * List<Localizacion> ListDat = new List<Localizacion>(); * ListDat.Add(new Localizacion() { Estado = "Lima", Ciudad = "Lima Central", Pais = "Perú", Estacion = "Perú 1" }); * ListDat.Add(new Localizacion() { Estado = "Trujillo", Ciudad = "Central Trujillo", Pais = "Perú", Estacion = "Perú 2" }); * ListDat.Add(new Localizacion() { Estado = "Cajamarca", Ciudad = "Cajamarca Central", Pais = "Perú", Estacion = "Perú 3" }); * ListDat.Add(new Localizacion() { Estado = "Sullana", Ciudad = "Sullana Central", Pais = "Perú", Estacion = "Perú 4" }); * ListDat.Add(new Localizacion() { Estado = "Piura", Ciudad = "Piura Central", Pais = "Perú", Estacion = "Perú 5" }); * ListDat.Add(new Localizacion() { Estado = "Chiclayo", Ciudad = "Chiclayo Central", Pais = "Perú", Estacion = "Perú 6" }); */ FileStream fs = new FileStream(filepath, FileMode.OpenOrCreate); formatter.Serialize(fs, ListDat); fs.Close(); }
public void Update(Localizacion localizacion) { crudLocalizacion.Update(localizacion); }
public void Delete(Localizacion localizacion) { crudLocalizacion.Delete(localizacion); }
public ResponseViewModel Create(CreateEventoViewModel model) { ResponseViewModel reponse = new ResponseViewModel(); try { model.FechaFinG = DateTime.Parse(model.FechaFin); model.FechaInicioG = DateTime.Parse(model.FechaInicio); Evento ev = new Evento { Nombre = model.Nombre, Descripcion = model.Descripcion, Imagen = model.ImagenMiniatura, FechaInicio = model.FechaInicioG, FechaFin = model.FechaFinG, Activo = "1", IdTipo = model.IdTipo, FechaRegistro = DateTime.Now }; _eventPlusContext.Evento.Add(ev); _eventPlusContext.SaveChanges(); EventoUsuario evUs = new EventoUsuario { IdEvento = ev.Id, IdLogin = model.IdLogin }; _eventPlusContext.EventoUsuario.Add(evUs); _eventPlusContext.SaveChanges(); if (model.Localizacion != null) { foreach (var lista in model.Localizacion) { Localizacion local = new Localizacion { IdEvento = ev.Id, Activo = "1", Comentario = lista.Comentario, Direccion = lista.Direccion, FechaRegistro = DateTime.Now, Latitud = lista.Latitud, Longitud = lista.Longitud }; _eventPlusContext.Localizacion.Add(local); _eventPlusContext.SaveChanges(); } } reponse.Type = "success"; reponse.Response = "El regitsro se creo exitosamente."; return(reponse); } catch (Exception ex) { reponse.Type = "error"; reponse.Response = "Error en el procedimiento. ---> " + ex.Message; return(reponse); } }
/// <summary> /// Handle /// </summary> /// <param name="request"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public override async Task <bool> Handle(BulkLocationsRequest request, CancellationToken cancellationToken) { (string[], string[][])csv = await BulkUtils.ReadCsvAsync(request.LocationsFile, cancellationToken).ConfigureAwait(false); string[] headers = csv.Item1; string[][] data = csv.Item2; if (!data.Any()) { return(false); } Localizacion.SetPropertyIndexes(headers); Area.SetPropertyIndexes(headers); Region.SetPropertyIndexes(headers); Pais.SetPropertyIndexes(headers); List <string> existentLocations = await repository.GetAll().Select(u => u.Nombre).ToListAsync().ConfigureAwait(false); List <Area> existentAreas = (await areaRepository.GetAll() .Select(a => new { a.Region.IdPais, Area = a }).ToListAsync().ConfigureAwait(false)) .Select(x => { var aNew = x.Area; aNew.IdPais = x.IdPais; return(aNew); }).ToList(); List <Region> existentRegions = await regionRepository.GetAll().ToListAsync().ConfigureAwait(false); List <Pais> existentPaises = await paisRepository.GetAll().ToListAsync().ConfigureAwait(false); List <Localizacion> newLocalizaciones = new List <Localizacion>(); List <Area> newAreas = new List <Area>(); List <Region> newRegions = new List <Region>(); List <Pais> newPaises = new List <Pais>(); int indexArea = existentAreas.Max(p => p.Id); int indexRegion = existentRegions.Max(p => p.Id); int indexPais = existentPaises.Max(p => p.Id); foreach (string[] dataRow in data) { Localizacion newLocalizacion = new Localizacion(dataRow); Area newArea = new Area(dataRow); Region newRegion = new Region(dataRow); Pais newPais = new Pais(dataRow); if (!string.IsNullOrEmpty(newPais.Nombre)) { if (existentPaises.Any(p => p.Nombre == newPais.Nombre)) { newPais = existentPaises.Single(p => p.Nombre == newPais.Nombre); } else if (newPaises.Any(p => p.Nombre == newPais.Nombre)) { newPais = newPaises.Single(p => p.Nombre == newPais.Nombre); } else { indexPais++; newPais.Id = indexPais; newPais.LastAction = "CREATE"; newPais.LastActionDate = DateTime.UtcNow; newPaises.Add(newPais); } if (!string.IsNullOrEmpty(newRegion.Nombre)) { if (existentRegions.Any(p => p.Nombre == newRegion.Nombre)) { newRegion = existentRegions.Single(p => p.Nombre == newRegion.Nombre); } else if (newRegions.Any(p => p.Nombre == newRegion.Nombre)) { newRegion = newRegions.Single(p => p.Nombre == newRegion.Nombre); } else { indexRegion++; newRegion.Id = indexRegion; newRegion.IdPais = newPais.Id; newRegion.LastAction = "CREATE"; newRegion.LastActionDate = DateTime.UtcNow; newRegions.Add(newRegion); } } else if (!string.IsNullOrEmpty(newArea.Nombre)) { if (existentRegions.Any(p => p.Nombre == newArea.Nombre)) { newRegion = existentRegions.Single(p => p.Nombre == newArea.Nombre); } else if (newRegions.Any(p => p.Nombre == newArea.Nombre)) { newRegion = newRegions.Single(p => p.Nombre == newArea.Nombre); } else { indexRegion++; newRegion.Id = indexRegion; newRegion.Nombre = newArea.Nombre; newRegion.IdPais = newPais.Id; newRegion.LastAction = "CREATE"; newRegion.LastActionDate = DateTime.UtcNow; newRegions.Add(newRegion); } } if (!string.IsNullOrEmpty(newArea.Nombre)) { if (existentAreas.Any(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id)) { newArea = existentAreas.Single(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id); } else if (newAreas.Any(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id)) { newArea = newAreas.Single(p => p.Nombre == newArea.Nombre && p.IdPais == newPais.Id); } else { indexArea++; newArea.Id = indexArea; newArea.IdRegion = newRegion.Id; newArea.IdPais = newPais.Id; newArea.LastAction = "CREATE"; newArea.LastActionDate = DateTime.UtcNow; newAreas.Add(newArea); } } } if (existentLocations.Contains(newLocalizacion.Nombre)) { continue; } newLocalizacion.IdArea = null; if (!string.IsNullOrEmpty(newArea.Nombre)) { newLocalizacion.IdArea = newArea.Id; } newLocalizacion.LastAction = "CREATE"; newLocalizacion.LastActionDate = DateTime.UtcNow; newLocalizaciones.Add(newLocalizacion); } await paisRepository.BulkInsertAsync(newPaises).ConfigureAwait(false); await regionRepository.BulkInsertAsync(newRegions).ConfigureAwait(false); await areaRepository.BulkInsertAsync(newAreas).ConfigureAwait(false); await repository.BulkInsertAsync(newLocalizaciones).ConfigureAwait(false); //repository.AddRange(newLocalizaciones); //await repository.SaveChangesAsync().ConfigureAwait(false); return(true); }