/// <summary>
 /// Builds the entity with amount of competitors and laps.
 /// </summary>
 /// <param name="cantidadCompetidores">Amount of competitors</param>
 /// <param name="cantidadVueltas">Number of total laps.</param>
 /// <param name="competenciaDe">Type of competence.</param>
 public Competencia(short cantidadCompetidores, short cantidadVueltas, TipoCompetencia competenciaDe)
     : this()
 {
     this.CantidadCompetidores = cantidadCompetidores;
     this.CantidadVueltas      = cantidadVueltas;
     this.Tipo = competenciaDe;
 }
Example #2
0
 public Competencia(short cantVueltas, short cantCompetidores, TipoCompetencia tipo)
     : this()
 {
     this.CantidadVueltas      = cantVueltas;
     this.CantidadCompetidores = cantCompetidores;
     this.Tipo = tipo;
 }
Example #3
0
 public Competencia(short vuelta, short competidores, TipoCompetencia tipo)
     : this()
 {
     this.cantidadVueltas      = vuelta;
     this.cantidadCompetidores = competidores;
     this.tipo = tipo;
 }
Example #4
0
        /// <summary>
        /// Devuelve true si el auto es del mismo tipo
        /// y no forma parte de la competencia
        /// </summary>
        /// <param name="c"></param>
        /// <param name="a"></param>
        /// <returns></returns>
        public static bool operator ==(Competencia c, VehiculoDeCarrera a)
        {
            int  i;
            bool noFormaParte = true;

            TipoCompetencia tipo;

            tipo = c.Tipo;

            switch (tipo)
            {
            case Competencia.TipoCompetencia.F1:
                if (a is AutoF1)
                {
                    for (i = 0; i < c.competidores.Count; i++)
                    {
                        if (c[i] == a)
                        {
                            noFormaParte = false;
                        }
                    }
                }
                else
                {
                    noFormaParte = false;
                }
                break;

            case Competencia.TipoCompetencia.MotoCross:
                if (a is MotoCross)
                {
                    for (i = 0; i < c.competidores.Count; i++)
                    {
                        if (c[i] == a)
                        {
                            noFormaParte = false;
                        }
                    }
                }
                else
                {
                    noFormaParte = false;
                }
                break;

            default:
                noFormaParte = false;
                break;
            }

            if (noFormaParte == false)
            {
                throw new CompetenciaNoDisponibleException("El vehĂ­culo no corresponde a la competencia",
                                                           "Vehiculo", "operator ==");
            }

            return(noFormaParte);
        }
 public async Task Create(TipoCompetencia model)
 {
     try
     {
         _db.tipoCompetencia.Add(model);
         await _db.SaveChangesAsync();
     }
     catch (Exception e)
     {
         throw new Exception(e.Message, e);
     }
 }
Example #6
0
        public static bool operator ==(Competencia <T> c, T a)
        {
            TipoCompetencia tipo;

            tipo = (a.GetType() == typeof(AutoF1)) ? TipoCompetencia.F1 : TipoCompetencia.MotoCross;
            bool retorno = c.tipo == tipo;

            if (retorno == false)
            {
                throw new CompetenciaNoDisponibleException("El vehiculo no existe en la competencia", "Competencia", "==");
            }
            return(retorno);
        }
Example #7
0
        public object SelecionaCompetencia(TipoCompetencia tipo)
        {
            switch (tipo)
            {
            case TipoCompetencia.MesAno:
                return(dataDeVencimento.CompetenciaMesAno);

            case TipoCompetencia.Ano:
                return(dataDeVencimento.CompetenciaAno);

            case TipoCompetencia.Mes:
                return(dataDeVencimento.CompetenciaMes);
            }
            return(null);
        }
        public async Task Update(TipoCompetencia model)
        {
            try
            {
                var _model = await _db.tipoCompetencia.FirstOrDefaultAsync(e => e.TipoCompetenciaId == model.TipoCompetenciaId);

                if (_model != null)
                {
                    _db.Entry(_model).CurrentValues.SetValues(model);
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
        public async Task UpdateEstado(TipoCompetencia obj)
        {
            try
            {
                var _obj = await _db.tipoCompetencia.FirstOrDefaultAsync(e => e.TipoCompetenciaId == obj.TipoCompetenciaId);

                if (_obj != null)
                {
                    _obj.estado = obj.estado;
                    await _db.SaveChangesAsync();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message, e);
            }
        }
Example #10
0
        public static bool operator +(Competencia c, VehiculoCarrera a)
        {
            TipoCompetencia tipo;

            tipo = (a.GetType() == typeof(AutoF1)) ? TipoCompetencia.F1 : TipoCompetencia.MotoCross;
            if ((c.competidores.Count() >= c.CantidadCompetidores && c == a) || c.Tipo != tipo)
            {
                return(false);
            }
            else
            {
                c.competidores.Add(a);
                a.EnCompetencia    = true;
                a.VueltasRestantes = c.CantidadVueltas;
                Random vueltas = new Random();
                a.CantidadCombustible = (short)vueltas.Next(15, 101);
                return(false);
            }
        }
Example #11
0
 public Competencia(short cantidadVueltas, short cantidadCompetidores, TipoCompetencia competencia) : this()
 {
     this.cantidadVueltas      = cantidadVueltas;
     this.cantidadCompetidores = cantidadCompetidores;
     this.tipo = competencia;
 }
Example #12
0
 public Competencia(short cantidadVueltas, short cantidadCompetidores, TipoCompetencia tipo)
 {
     this.tipo = tipo;
 }
Example #13
0
 public Competencia(Int16 cantidadVueltas, Int16 cantidadCompetidores, TipoCompetencia tipo) : this()
 {
     this.CantidadCompetidores = cantidadCompetidores;
     this.CantidadVueltas      = cantidadVueltas;
     this.Tipo = tipo;
 }
 public Competencia(short cVueltas, short cCompetidores, TipoCompetencia tipo) : this()
 {
     this._cantidadVueltas      = cVueltas;
     this._cantidadCompetidores = cCompetidores;
     this._tipo = tipo;
 }
Example #15
0
                                                             public async Task <IHttpActionResult> UpdateEstado(TipoCompetencia obj)
                                                             {
                                                                 try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                       await _repository.UpdateEstado(obj);

                                                                       return(Ok("Registro actualizado correctamente!")); }
                                                                 catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);

                                                                                       return(InternalServerError(e)); }
                                                             }
Example #16
0
                                                             [HttpPost][Authorize] public async Task <IHttpActionResult> Create(TipoCompetencia obj)
                                                             {
                                                                 try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                       await _repository.Create(obj);

                                                                       return(Ok("El tipo de competencia se ha registrado correctamente!")); }
                                                                 catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                       return(InternalServerError(e)); }
                                                             }