/*Añade una evento a la base de datos, ya sea una cartelera o un festival */ public void añadirEvento(eventos pEvento, List <categoriasevento> categoriasBanda) { eventos nuevoEvento = null; using (myconcertEntities context = new myconcertEntities()) { using (var dbContextTransaction = context.Database.BeginTransaction()) { try { nuevoEvento = context.eventos.Add(pEvento); foreach (categoriasevento cat_eve in categoriasBanda) { cat_eve.FK_CATEGORIASEVENTO_EVENTOS = nuevoEvento.PK_eventos; context.categoriasevento.Add(cat_eve); } context.SaveChanges(); dbContextTransaction.Commit(); } catch (Exception ex) { dbContextTransaction.Rollback(); throw (ex); } } } }
public async Task <IActionResult> Puteventos([FromRoute] int id, [FromBody] eventos eventos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eventos.idEvento) { return(BadRequest()); } _context.Entry(eventos).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!eventosExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public ActionResult CreateEvent(eventos Newevent, HttpPostedFileBase img) { using (db_globalesEntities2 db = new db_globalesEntities2()) { //upload folder exist if (!Directory.Exists(Server.MapPath("~/Images/Eventos"))) { Directory.CreateDirectory(Server.MapPath("~/Images/Eventos")); } //save image on local storage var path = Path.Combine(Server.MapPath("~/Images/Eventos"), img.FileName); img.SaveAs(path); Newevent.imagen = img.FileName; Newevent.propietario = Session["UserID"].ToString(); //empresa exists var empresa = db.eventos.Where(x => x.id == Newevent.id).FirstOrDefault(); if (empresa == null) { db.eventos.Add(Newevent); db.SaveChanges(); } } return(RedirectToAction("Index", "Home")); }
public IHttpActionResult Puteventos(int id, eventos eventos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != eventos.Id) { return(BadRequest()); } db.Entry(eventos).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!eventosExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public EventoDetalleDTViewModel(eventos evento) { Label nombrePaciente = new Label() { FontSize = 12, FontFamily = Device.OnPlatform("OpenSans-Bold", "OpenSans-Bold", null), TextColor = Color.FromHex("404040"), }; nombrePaciente.Text = evento.asunto; var contenedor = new StackLayout() { Spacing = 0, Padding = new Thickness(5, 0, 0, 0), VerticalOptions = LayoutOptions.Center, Children = { nombrePaciente, new EventoHoraDTViewModel(evento) } }; Content = contenedor; }
public ActionResult DeleteConfirmed(int id) { eventos eventos = db.Eventos.Find(id); db.Eventos.Remove(eventos); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "id,evento,fecha,hora")] eventos eventos) { if (ModelState.IsValid) { db.Entry(eventos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public ActionResult Edit([Bind(Include = "eventosId,Title,Description,StartDate,EndDate,Status")] eventos eventos) { if (ModelState.IsValid) { db.Entry(eventos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
// // GET: /Eventos/Delete/5 public ActionResult Delete(int id = 0) { eventos eventos = db.eventos.Find(id); if (eventos == null) { return(HttpNotFound()); } return(View(eventos)); }
public ActionResult Edit(eventos eventos) { if (ModelState.IsValid) { db.Entry(eventos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public ActionResult Edit([Bind(Include = "Id,DataEvento,Tag,Valor,Estado")] eventos eventos) { if (ModelState.IsValid) { db.Entry(eventos).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public ActionResult Create([Bind(Include = "id,evento,fecha,hora")] eventos eventos) { if (ModelState.IsValid) { db.eventos.Add(eventos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public ActionResult Create([Bind(Include = "eventosId,Title,Description,StartDate,EndDate,Status")] eventos eventos) { if (ModelState.IsValid) { db.Eventos.Add(eventos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public ActionResult delete(int id) { eventos eventoToRemove = db.eventos.Where(x => x.id == id).FirstOrDefault(); db.eventos.Remove(eventoToRemove); db.SaveChanges(); List <eventos> eventosList = getEventosList(); return(PartialView("/Views/dashboard/eventosList.cshtml", eventosList)); }
public ActionResult Create(eventos eventos) { if (ModelState.IsValid) { db.eventos.Add(eventos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public IHttpActionResult Geteventos(int id) { eventos eventos = db.eventos.Find(id); if (eventos == null) { return(NotFound()); } return(Ok(eventos)); }
public ActionResult Create([Bind(Include = "Id,DataEvento,Tag,Valor,Estado")] eventos eventos) { if (ModelState.IsValid) { db.eventos.Add(eventos); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(eventos)); }
public async Task <IActionResult> Posteventos([FromBody] eventos eventos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.eventos.Add(eventos); await _context.SaveChangesAsync(); return(CreatedAtAction("Geteventos", new { id = eventos.idEvento }, eventos)); }
public IHttpActionResult Posteventos(eventos eventos) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.eventos.Add(eventos); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = eventos.Id }, eventos)); }
//Obtener evento especifico public Respuesta getEvento(int pID) { Respuesta respuesta = null; try { //Busca la información solicitada eventos eventoSolicitado = _manejador.obtenerEvento(pID); List <categorias> listaCategoriasEvento = _manejador.obtenerCategoriasEvento(eventoSolicitado.PK_eventos); List <categorias> categoriasSinRepetir = generarCategorias(listaCategoriasEvento); //Si el evento es una cartelera if (eventoSolicitado.FK_EVENTOS_TIPOSEVENTOS == _manejador.obtenerTipoEvento(1).PK_tiposEventos) { JObject[] categoriasEventoEspecifico = obtenerCategoriasCartelera(pID, categoriasSinRepetir); Evento eventoAuxiliar = _convertidor.createEvento(eventoSolicitado); //Cartelera obtenida correctamente respuesta = _fabricaRespuestas.crearRespuesta(true, categoriasEventoEspecifico, JObject.FromObject(eventoAuxiliar)); } //Si el evento es un festival else if (eventoSolicitado.FK_EVENTOS_TIPOSEVENTOS == _manejador.obtenerTipoEvento(2).PK_tiposEventos) { List <bandas> bandasFestival = extraerBandasEvento(eventoSolicitado, categoriasSinRepetir); List <JObject> bandasEnvio = new List <JObject>(); dynamic banda_envio; foreach (bandas bandaActual in bandasFestival) { banda_envio = new JObject(); banda_envio.name_band = bandaActual.nombreBan; banda_envio.votes = _manejador.obtenerCantidadVotos(eventoSolicitado.PK_eventos, bandaActual.PK_bandas); bandasEnvio.Add(banda_envio); } Evento evento = _convertidor.createEvento(eventoSolicitado); FestivalBandas fest = new FestivalBandas(JObject.FromObject(evento), bandasEnvio.ToArray()); //Festival obtenido correctamente respuesta = _fabricaRespuestas.crearRespuesta(true, JObject.FromObject(fest)); } else { respuesta = _fabricaRespuestas.crearRespuesta(false, "Error: Evento no existente."); } } catch (Exception) { //Mensaje de error respuesta = _fabricaRespuestas.crearRespuesta(false, "Error: Error al procesar información. Por favor intente de nuevo."); } //Retorna respuesta return(respuesta); }
public IHttpActionResult Deleteeventos(int id) { eventos eventos = db.eventos.Find(id); if (eventos == null) { return(NotFound()); } db.eventos.Remove(eventos); db.SaveChanges(); return(Ok(eventos)); }
// GET: eventos/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } eventos eventos = db.Eventos.Find(id); if (eventos == null) { return(HttpNotFound()); } return(View(eventos)); }
public int InsertEvento(eventos evento) { lock (locker) { if (evento.id != 0) { database.Update(evento); return(evento.id); } else { return(database.Insert(evento)); } } }
//Crear votaciones public Respuesta nuevaVotacion(JArray pCategorias) { Respuesta respuesta = null; List <votos> listaVotaciones = null; try { //Organiza la informacion de votos listaVotaciones = generarVotos(pCategorias); //Comprobar que el fanatico no haya votado previamente en cartelera votos votoActual = listaVotaciones[0]; usuarios userActual = _manejador.obtenerUsuario(votoActual.FK_VOTOS_USUARIOS); eventos eventoActual = _manejador.obtenerEvento(votoActual.FK_VOTOS_EVENTOS); if (_manejador.verificarVotoUsuario(userActual, eventoActual)) { return(_fabricaRespuestas.crearRespuesta(false, "El usuario " + userActual.username + " ya había realizado su única votación en esta cartelera.")); } List <List <votos> > matrizVotos = mapearVotacionesPorCategoria(listaVotaciones); if (!comprobarEstrategiaCienDolares(matrizVotos)) { //Retorna mensaje de error por no cumplir con la estrategia de los cien dolares respuesta = _fabricaRespuestas.crearRespuesta(false, "Error: Es necesario completar los cien créditos en todas las categorías. Por favor intente de nuevo."); } } catch (Exception) { respuesta = _fabricaRespuestas.crearRespuesta(false, "Error al interpretar votaciones. Por favor intente de nuevo."); //respuesta = _fabricaRespuestas.crearRespuesta(false, "Error al interpretar votaciones.", e.ToString()); } try { _manejador.añadirVotos(listaVotaciones); respuesta = _fabricaRespuestas.crearRespuesta(true, "Votacion procesada satisfactoriamente."); } catch (Exception) { //Retorna mensaje de error respuesta = _fabricaRespuestas.crearRespuesta(false, "Error al procesar votacion. Por favor intente de nuevo."); //respuesta = _fabricaRespuestas.crearRespuesta(false, "Error al procesar votacion. Por favor intente de nuevo.", e.ToString()); } //Retorna respuesta respectiva return(respuesta); }
public eventos updateeventos(Cartelera pEvento) { eventos event_carte = new eventos(); event_carte.PK_eventos = pEvento.Id; event_carte.nombreEve = pEvento.Nombre; event_carte.ubicacion = pEvento.Ubicacion; event_carte.FK_EVENTOS_PAISES = _manejadorDB.obtenerPais(pEvento.Pais).PK_paises; event_carte.fechaInicio = pEvento.FechaInicioFestival; event_carte.fechaFinal = pEvento.FechaInicioFestival; event_carte.finalVotacion = pEvento.FechaFinalVotacion; event_carte.FK_EVENTOS_TIPOSEVENTOS = _manejadorDB.obtenerTipoEvento(pEvento.TipoEvento).PK_tiposEventos; event_carte.FK_EVENTOS_ESTADOS = _manejadorDB.obtenerEstado(pEvento.Estado).PK_estados; return(event_carte); }
/* */ public eventos obtenerEvento(int PK_evento) { eventos obj = null; try { using (myconcertEntities context = new myconcertEntities()) { obj = context.eventos.FirstOrDefault(r => r.PK_eventos == PK_evento); } } catch (Exception ex) { throw (ex); } return(obj); }
//Extraer las bandas de un evento específico private List <bandas> extraerBandasEvento(eventos nuevoEvento, List <categorias> categoriasCartelera) { List <bandas> todasBandasCartelera = new List <bandas>(); foreach (categorias categoriaActual in categoriasCartelera) { foreach (bandas bandaActual in _manejador.obtenerBandasCategoria(categoriaActual.PK_categorias, nuevoEvento.PK_eventos)) { if (!existeEnLista(todasBandasCartelera, bandaActual)) { todasBandasCartelera.Add(bandaActual); } } } return(todasBandasCartelera); }
public static eventos ConvertEventToDb(Eventos oldEvento) { eventos newEvento = new eventos(); newEvento.id = oldEvento.id; newEvento.titulo = oldEvento.titulo; newEvento.imagem = oldEvento.imagem; newEvento.latitude = oldEvento.latitude; newEvento.longitude = oldEvento.longitude; newEvento.modificadoPor = oldEvento.modificadoPor; newEvento.datafim = oldEvento.datafim; newEvento.datainicio = oldEvento.datainicio; newEvento.descricao = oldEvento.descricao; newEvento.subtitulo = oldEvento.subtitulo; newEvento.Users = oldEvento.Users; return(newEvento); }
//Devolvemos lista de asistir de las valoraciones del evento public static List <asistir> SelectAllValoracion(eventos evento) { List <asistir> asistir = null; try { asistir = ( from e in ORM.bd.asistir where e.id_evento == evento.id && e.valoracion != 0 select e).ToList(); } catch (EntityException ex) { SqlException sqlEx = (SqlException)ex.InnerException.InnerException; MessageBox.Show(ex.Message, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return(asistir); }
/** * @brief Funcion que solicita dependencias y ejecuta el algoritmo del chef según los parámetros indicados. * @param pwinners Lista de bandas ganadoras. * @param id_fest El identificador del evento a realzarse. */ public string executeChefProcess(List <string> pBandasString, List <bandas> pwinners, int id_fest) { /* ALGORITMO DEL CHEF */ Console.WriteLine("Inicio Algoritmo del Chef"); eventos _evento = _manejador.obtenerEvento(id_fest); List <bandas> other_bands = _manejador.obtenerBandasNoCartelera(_evento); Console.WriteLine("********* other_bands ********"); foreach (bandas bandaActual in other_bands) { Console.WriteLine(bandaActual.nombreBan); } Console.WriteLine("*******************************"); List <string> _otherString = getBandsNames(other_bands); /* POR MIENTRAS: winner_songs */ List <List <canciones> > winner_songs = getAllSongsArtists(pwinners); List <List <canciones> > other_songs = getAllSongsArtists(other_bands); Chef _chef = new Chef(); try { return(_chef.chefAlgorythm(pBandasString, _otherString, winner_songs, other_songs)); /*SE SOLICITA INFO A LA BASE DE DATOS RESPECTO A LA BANDA*/ /*SE GENERA LA BANDA RECOMENDADA*/ } catch (Exception) { List <float> amount_comments_other = getComments(other_bands); List <float> amount_comments_winners = getComments(pwinners); List <float> amount_stars_other = getRating(other_bands); List <float> amount_stars_winners = getRating(pwinners); Console.WriteLine("Error: No hay suficiente informacion de las bandas en Spotify..."); Console.WriteLine("Algoritmo del Chef alternativo"); return(_chef.alternativeChefAlgorythm(pBandasString, _otherString, amount_comments_other, amount_stars_other, amount_comments_winners, amount_stars_winners)); } }