Exemple #1
0
        public async Task <ActionResult <TypeVoiture> > PostTypeVoiture(TypeVoiture typeVoiture)
        {
            _context.typeVoitures.Add(typeVoiture);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTypeVoiture", new { id = typeVoiture.Id }, typeVoiture));
        }
Exemple #2
0
        public async Task <IActionResult> PutTypeVoiture(int id, TypeVoiture typeVoiture)
        {
            if (id != typeVoiture.Id)
            {
                return(BadRequest());
            }

            _context.Entry(typeVoiture).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TypeVoitureExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #3
0
        /**
         * Constructeur pour vehicule d'occasion
         */

        public Voiture(string marque, string modele, int km, string couleur, int nbPortes, int puissance, TypeVoiture type) : base(marque, modele, km, couleur)
        {
            this.nbPortes  = nbPortes;
            this.puissance = puissance;
            this.type      = type;
            CalculerCout();
        }
Exemple #4
0
        /**
         * Verifie la validité des donnée et ajout une Voiture à la liste de véhicule du gestionnaire de flotte
         * @Params couleur   string   : couleur du véhicule
         * @Params km        int      : km au compteur
         * @Params marque    string   : marque du véhicule
         * @Params modele    string   : modele du véhicule
         * @Params nbPortes  int      : nombre de portes
         * @Params puissance int      : puissance moteur (nombre de chevaux)
         */
        public void AjoutVoiture(string couleur, string km, string marque, string modele, string nbPortes, string puissance, string type)
        {
            int         iKm         = -1;
            int         iNbPortes   = -1;
            int         iPuissances = -1;
            TypeVoiture typeV;

            CheckVehicule(couleur, km, marque, modele, out iKm);


            if (!TypeVoiture.TryParse(type, true, out typeV))
            {
                throw new ErreurType();
            }
            if (!int.TryParse(nbPortes, out iNbPortes) || iNbPortes < 3 || iNbPortes > 5)
            {
                throw new ErreurNBPortes();
            }
            if (!int.TryParse(puissance, out iPuissances) || iPuissances < 70 || iPuissances > 650)
            {
                throw new ErreurPuissance();
            }

            gestionFlotte.AjoutVehicule(new Voiture(marque, modele, iKm, couleur, iNbPortes, iPuissances, typeV));
        }
Exemple #5
0
 public Voiture(int nVehicule, string marque, string modele, int km, string couleur, bool isDisponible,
                Place place, List <Intervention> interventionList, int nTrajet, int nbPortes, int puissance, TypeVoiture type) : base(
         nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet)
 {
     this.nbPortes  = nbPortes;
     this.puissance = puissance;
     this.type      = type;
     CalculerCout();
 }
 public BaseVoiture(int id, string modele, bool dispo, TypeVoiture type, DateTime dateDispoStart, DateTime dateDispoEnd, BaseAgence agence)
 {
     Id             = id;
     Modele         = modele;
     Disponible     = dispo;
     Type           = type;
     DateDispoStart = dateDispoStart;
     DateDispoEnd   = dateDispoEnd;
     Agence         = agence;
 }
Exemple #7
0
        public async Task <IActionResult> Post([FromBody] TypeVoiture model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            await _unitOfWork.TypeVoitures.AddAsync(model);

            int i = await _unitOfWork.Complete();

            return(Ok(i));
        }
Exemple #8
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] TypeVoiture model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != model.Id)
            {
                return(BadRequest());
            }

            _unitOfWork.TypeVoitures.Update(model);

            await _unitOfWork.Complete();

            return(NoContent());
        }
Exemple #9
0
        public bool ChargerVehicules(JToken jToken)

        {
            jToken = jToken.First;
            bool erreur        = false;
            int  lastNVehicule = 0;
            int  i             = 0;

            while (jToken != null)
            {
                try
                {
                    int    nVehicule    = int.Parse(jToken["nVehicule"].ToString());
                    string marque       = jToken["marque"].ToString();
                    string modele       = jToken["modele"].ToString();
                    int    km           = int.Parse(jToken["km"].ToString());
                    string couleur      = jToken["couleur"].ToString();
                    bool   isDisponible = bool.Parse(jToken["isDisponible"].ToString());
                    string parking      = jToken["parking"].ToString();
                    string strPlace     = jToken["place"].ToString();

                    Place place;
                    if (strPlace == "null")
                    {
                        place = null;
                    }
                    else
                    {
                        place = gestionFlotte.ParkingList.FindLast(p => p.Nom == parking).Places[int.Parse(strPlace.Substring(1))];
                    }

                    JToken subtJToken = jToken["interventionList"].First;
                    List <Intervention> interventionList = new List <Intervention>();
                    while (subtJToken != null)
                    {
                        Intervention interv;
                        Intervention.TryParse(subtJToken["intervention"].ToString(), out interv);
                        interventionList.Add(interv);
                        subtJToken = subtJToken.Next;
                    }
                    int    nTrajet   = int.Parse(jToken["nTrajet"].ToString());
                    string vehiculeT = jToken["vehicule"].ToString();
                    if (vehiculeT.ToUpper() == "VOITURE")
                    {
                        int         nbPortes  = int.Parse(jToken["nbPortes"].ToString());
                        int         puissance = int.Parse(jToken["puissance"].ToString());
                        TypeVoiture type;
                        TypeVoiture.TryParse(jToken["type"].ToString(), out type);
                        gestionFlotte.VehiculeList.Add(new Voiture(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, nbPortes, puissance, type));
                    }
                    else if (vehiculeT.ToUpper() == "MOTO")
                    {
                        int cylindre = int.Parse(jToken["cylindre"].ToString());
                        gestionFlotte.VehiculeList.Add(new Moto(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, cylindre));
                    }
                    else if (vehiculeT.ToUpper() == "CAMION")
                    {
                        int capacite = int.Parse(jToken["capacite"].ToString());
                        gestionFlotte.VehiculeList.Add(new Moto(nVehicule, marque, modele, km, couleur, isDisponible, place, interventionList, nTrajet, capacite));
                    }

                    if (lastNVehicule < nVehicule)
                    {
                        lastNVehicule = nVehicule;
                    }
                }
                catch (Exception e)
                {
                    erreur = true;
                }

                jToken = jToken.Next;
            }

            Vehicule.LastNVehicule = lastNVehicule;
            return(erreur);
        }