public IHttpActionResult PutTorneo(int id, Torneo torneo) { try { torneo.ID = id; using (var proxy = new WSTorneo.TorneoServiceClient()) { proxy.ActualizarTorneo(torneo); return Ok(new { success = true }); } } catch (Exception) { return Ok(new { success = false, message = "No se ha podido grabar el torneo, vuelva a intentarlo más tarde." }); } }
public int CrearTorneo(int idUsuario, Torneo torneo) { if (string.IsNullOrEmpty(torneo.Nombre) || torneo.FechaInicio == null || torneo.FechaFin == null || torneo.NumeroParticipantes == 0 || torneo.NumeroContendores == 0 || string.IsNullOrEmpty(torneo.Enlace)) throw new FaultException("Información básica del torneo incompleta"); if (torneo.NumeroParticipantes % 2 == 0) throw new FaultException("Participantes debe ser impar"); if (!Validador.EsPotenciaDe2(torneo.NumeroContendores)) throw new FaultException("Contendores debe ser potencia de 2"); if (torneo.FechaFin < DateTime.Today) throw new FaultException("Fecha fin debe ser futura"); if (torneo.FechaInicio > torneo.FechaFin) throw new FaultException("Fecha inicio debe ser menor a fecha fin"); if (torneoDA.ObtenerTorneo(torneo.Nombre) != null) throw new FaultException("El nombre del torneo ya esta registrado"); return torneoDA.CrearTorneo(idUsuario, torneo); }
public void ActualizarTorneo(Torneo torneo) { var xtorneo = torneoDA.ObtenerTorneo(torneo.ID); if (xtorneo == null) throw new FaultException("Torneo no existe"); if (string.IsNullOrEmpty(torneo.Nombre) || torneo.FechaInicio == null || torneo.FechaFin == null || torneo.NumeroParticipantes == 0 || torneo.NumeroContendores == 0 || string.IsNullOrEmpty(torneo.Enlace)) throw new FaultException("Información básica del torneo incompleta"); if (torneo.NumeroParticipantes % 2 == 0) throw new FaultException("Participantes debe ser impar"); if (!Validador.EsPotenciaDe2(torneo.NumeroContendores)) throw new FaultException("Contendores debe ser potencia de 2"); if (torneo.FechaFin < DateTime.Today) throw new FaultException("Fecha fin debe ser futura"); if (torneo.FechaInicio > torneo.FechaFin) throw new FaultException("Fecha inicio debe ser menor a fecha fin"); torneoDA.ActualizarTorneo(torneo); }
public int CrearTorneo(int idUsuario, Torneo torneo) { return this.ExecuteScalar<int>("usp_CrearTorneo", new DataParameter("@pNombre", torneo.Nombre), new DataParameter("@pNumeroParticipantes", torneo.NumeroParticipantes), new DataParameter("@pNumeroContendores", torneo.NumeroContendores), new DataParameter("@pFechaInicio", torneo.FechaInicio), new DataParameter("@pFechaFin", torneo.FechaFin), new DataParameter("@pEnlace", torneo.Enlace), new DataParameter("@pIDEstado", torneo.IDEstado), new DataParameter("@pIDUsuario", idUsuario) ); }
public void ActualizarTorneo(Torneo torneo) { this.ExecuteNonQuery("usp_ActualizarTorneo", new DataParameter("@pID", torneo.ID), new DataParameter("@pNombre", torneo.Nombre), new DataParameter("@pNumeroParticipantes", torneo.NumeroParticipantes), new DataParameter("@pNumeroContendores", torneo.NumeroContendores), new DataParameter("@pFechaInicio", torneo.FechaInicio), new DataParameter("@pFechaFin", torneo.FechaFin), new DataParameter("@pEnlace", torneo.Enlace), new DataParameter("@pIDEstado", torneo.IDEstado) ); }
public IHttpActionResult PostTorneo(int idUsuario, Torneo torneo) { try { using (var proxy = new WSTorneo.TorneoServiceClient()) { proxy.CrearTorneo(idUsuario, torneo); return Ok(new { success = true }); } } catch (Exception ex) { return Ok(new { success = false, message = ex.Message }); } }