コード例 #1
0
        public async Task <ActionResult <VehiculeType> > PostVehiculeType(VehiculeType vehiculeType)
        {
            _context.VehiculeTypes.Add(vehiculeType);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVehiculeType", new { id = vehiculeType.Id }, vehiculeType));
        }
コード例 #2
0
        /// <summary>
        /// Ajouter un statistique à la liste des statistiques avec une icon
        /// </summary>
        /// <param name="Name"></param>
        /// <param name="info"></param>
        private void AddStatistique(string Name, string info, VehiculeType Icon)
        {
            ListViewItem itm = new ListViewItem
            {
                Text = Name
            };

            itm.SubItems.Add(info);

            switch (Icon)
            {
            case VehiculeType.Automobile:
                itm.ImageIndex = 1;
                break;

            case VehiculeType.Moto:
                itm.ImageIndex = 0;
                break;

            case VehiculeType.Cyclomoteur:
                itm.ImageIndex = 0;
                break;
            }

            lvStats.Items.Add(itm);
        }
コード例 #3
0
        public async Task <IActionResult> PutVehiculeType(int id, VehiculeType vehiculeType)
        {
            if (id != vehiculeType.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #4
0
        private void btnCreation_Click(object sender, EventArgs e)
        {
            if (vehiculeRoulant != null)
            {
                MessageBox.Show("Instance déjà créée");
                return;
            }

            VehiculeType vehiculeType = (VehiculeType)cbxTypeVehicule.SelectedIndex;

            switch (vehiculeType)
            {
            case VehiculeType.Camion:
                vehiculeRoulant = new Camion();
                break;

            case VehiculeType.Voiture:
                vehiculeRoulant = new Voiture();
                break;

            case VehiculeType.Moto:
                vehiculeRoulant = new Moto();
                break;

            default: throw new Exception(string.Format("Unkown Vehicule Type : {0}", cbxTypeVehicule.Text));
            }
            ToggleButtons();

            txbCharge.Text      = vehiculeRoulant.Charge.ToString();
            txbDistance.Text    = vehiculeRoulant.Distance.ToString();
            txbPassagers.Text   = vehiculeRoulant.Passagers.ToString();
            txbVitesseMaxi.Text = vehiculeRoulant.VitesseMaxi.ToString();
            txbVitesseMini.Text = vehiculeRoulant.VitesseMini.ToString();
        }
コード例 #5
0
ファイル: DummyBad.cs プロジェクト: decarufe/MineSweeperKata
 private double GetSpeed(VehiculeType vehiculeType)
 {
     switch (vehiculeType)
       {
     case VehiculeType.Car:
       return GetBaseSpeed();
     case VehiculeType.Truck:
       return GetBaseSpeed()*LoadFactor();
     case VehiculeType.Plane:
       return GetBaseSpeed() - WindDragVector();
     default:
       throw new NotImplementedException();
       }
 }
コード例 #6
0
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OverHeadCost?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CalculatedTimeCost?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CalculatedDistanceCost?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CalculatedOwnershipCost?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (VehiculeType?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Volume?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CO2perKm?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AmortizationType?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (MaximumLoad?.GetHashCode() ?? 0);
            return(hashCode);
        }
コード例 #7
0
        public ActionResult Upsert(int?id)
        {
            VehiculeType = new VehiculeType();

            if (!id.HasValue)
            {
                return(View(VehiculeType));
            }

            VehiculeType = _context.VehiculeType.Find(id);

            if (VehiculeType == null)
            {
                return(NotFound());
            }

            return(View(VehiculeType));
        }
コード例 #8
0
        public ActionResult UpdateCreate([Bind("Id,Name")] VehiculeType vehiculeType)
        {
            Console.WriteLine(vehiculeType.Name);
            Console.WriteLine(vehiculeType.Id);
            if (ModelState.IsValid)
            {
                if (vehiculeType.Id == 0)
                {
                    _context.VehiculeType.Add(vehiculeType);
                }
                else
                {
                    _context.VehiculeType.Update(vehiculeType);
                }

                _context.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
コード例 #9
0
        public static Vehicule Create(VehiculeType type)
        {
            Vehicule vehicule;

            switch (type)
            {
            case VehiculeType.Car:
                vehicule = new Car();
                break;

            case VehiculeType.MotorCycle:
                vehicule = new Motorcycle();
                break;

            case VehiculeType.Bus:
                vehicule = new Bus();
                break;

            default:
                vehicule = null;
                break;
            }
            return(vehicule);
        }
コード例 #10
0
        /// <summary>
        /// Recherche par date de recu incluant un type de char
        /// </summary>
        private void FindLigue(VehiculeType typeChar)
        {
            CustomerCollection ClientList = _FormMain.ClientList;

            switch (typeChar)
            {
            case VehiculeType.Automobile:
                for (int i = 0; i < ClientList.Count; i++)
                {
                    if ((mcLigue1.SelectionStart.Date <= ClientList[i].DateInscription.Date) &&
                        (mcLigue2.SelectionStart.Date >= ClientList[i].DateInscription.Date))
                    {
                        if (!ClientList[i].ClientNull && (ClientList[i].TypeVehicule == VehiculeType.Manuel || ClientList[i].TypeVehicule == VehiculeType.Automatique))
                        {
                            AddClientToList(ClientList[i]);
                        }
                    }
                }
                break;

            case VehiculeType.Cyclomoteur:
                for (int i = 0; i < ClientList.Count; i++)
                {
                    if ((mcLigue1.SelectionStart.Date <= ClientList[i].DateInscription.Date) &&
                        (mcLigue2.SelectionStart.Date >= ClientList[i].DateInscription.Date))
                    {
                        if (!ClientList[i].ClientNull && (ClientList[i].TypeVehicule == VehiculeType.Cyclomoteur && !ClientList[i].IsSpyder))
                        {
                            AddClientToList(ClientList[i]);
                        }
                    }
                }
                break;

            case VehiculeType.Spyder:
                for (int i = 0; i < ClientList.Count; i++)
                {
                    if ((mcLigue1.SelectionStart.Date <= ClientList[i].DateInscription.Date) &&
                        (mcLigue2.SelectionStart.Date >= ClientList[i].DateInscription.Date))
                    {
                        if (!ClientList[i].ClientNull && (ClientList[i].TypeVehicule == VehiculeType.Cyclomoteur && ClientList[i].IsSpyder))
                        {
                            AddClientToList(ClientList[i]);
                        }
                    }
                }
                break;

            case VehiculeType.Moto:
                for (int i = 0; i < ClientList.Count; i++)
                {
                    if ((mcLigue1.SelectionStart.Date <= ClientList[i].DateInscription.Date) &&
                        (mcLigue2.SelectionStart.Date >= ClientList[i].DateInscription.Date))
                    {
                        if (!ClientList[i].ClientNull && (ClientList[i].TypeVehicule == VehiculeType.Moto))
                        {
                            AddClientToList(ClientList[i]);
                        }
                    }
                }
                break;

            default:
                for (int i = 0; i < ClientList.Count; i++)
                {
                    if ((mcLigue1.SelectionStart.Date <= ClientList[i].DateInscription.Date) &&
                        (mcLigue2.SelectionStart.Date >= ClientList[i].DateInscription.Date))
                    {
                        if (!ClientList[i].ClientNull && (ClientList[i].TypeVehicule == typeChar))
                        {
                            AddClientToList(ClientList[i]);
                        }
                    }
                }
                break;
            }
        }