Beispiel #1
0
 public ActionResult EditVehicule(Entity.Vehicule vehicule)
 {
     ViewBag.Title         = "Edit Company";
     ViewBag.postInfo      = "Company saved successfuly";
     ViewBag.postInfoClass = "alert-success";
     Console.WriteLine(vehicule.Id + ";" + vehicule.Name + ";" + vehicule.Description);
     using (var dao = new Dao.Dao())
     {
         if (!ModelState.IsValid)
         {
             var companiesList = dao.CompaniesList();
             var vehiculeTypes = new SelectList(new List <Object>
             {
                 new { Id = "BUS", Name = "BUS" },
                 new { Id = "TRAIN", Name = "Train" },
                 new { Id = "AVION", Name = "Avion" },
                 new { Id = "TAXI", Name = "Taxi" },
             }, "Id", "Name");
             ViewBag.vehiculeTypes = vehiculeTypes;
             ViewBag.listCompanies = new SelectList(companiesList, "Id", "Name");
             return(View(vehicule));
         }
         dao.UpdateVehicule(vehicule);
         return(View("Saved"));
     }
 }
Beispiel #2
0
 public ActionResult EditVehicule(int?id)
 {
     ViewBag.Title = "Edit Company";
     using (var dao = new Dao.Dao())
     {
         var companiesList = dao.CompaniesList();
         var vehiculeTypes = new SelectList(new List <Object>
         {
             new { Id = "BUS", Name = "Bus" },
             new { Id = "TRAIN", Name = "Train" },
             new { Id = "AVION", Name = "Avion" },
             new { Id = "TAXI", Name = "Taxi" },
         }, "Id", "Name");
         ViewBag.vehiculeTypes = vehiculeTypes;
         ViewBag.listCompanies = new SelectList(companiesList, "Id", "Name");
         Vehicule vehicule;
         if (id != null)
         {
             vehicule = dao.GetOneHVehicule((int)id);
             if (vehicule != null)
             {
                 return(View("editVehicule", vehicule));
             }
         }
         vehicule = new Vehicule();
         return(View("editVehicule", vehicule));
     }
 }
 public IHttpActionResult GetCompaniesList()
 {
     using (var dao = new Dao.Dao())
     {
         return(Json(dao.CompaniesList()));
     }
 }
Beispiel #4
0
 public ActionResult Index()
 {
     //get user companies list
     using (var dao = new Dao.Dao())
     {
         List <Company> companies = dao.CompaniesList();
         ViewData["vehicules"] = dao.VehiculesList();
         ViewData["companies"] = companies;
         ViewData["villes"]    = dao.VillesList();
         ViewData["voyages"]   = dao.VoyagesList();
         ViewBag.listCompanies = new SelectList(companies, "Id", "Name");
     }
     return(View("index"));
 }
Beispiel #5
0
        public ActionResult EditVoyage(int?id)
        {
            ViewBag.Title = "Edit Voyage";
            var vehiculeTypes = new SelectList(new List <Object>
            {
                new { Id = "BUS", Name = "Bus" },
                new { Id = "TRAIN", Name = "Train" },
                new { Id = "AVION", Name = "Avion" },
                new { Id = "TAXI", Name = "Taxi" },
            }, "Id", "Name");

            ViewBag.vehiculeTypes = vehiculeTypes;
            using (var dao = new Dao.Dao())
            {
                var listCompanies = dao.CompaniesList();
                ViewBag.listVilles    = new SelectList(dao.VillesList(), "Id", "Name");
                ViewBag.listCompanies = new SelectList(listCompanies, "Id", "Name");
                var listVehicules = listCompanies.Count > 0
                    ? dao.VehiculesListFor(listCompanies[0].Id)
                    : new List <Vehicule>();
                ViewBag.listVehicules = new SelectList(listVehicules, "Id", "Name");
                if (id != null)
                {
                    var v = dao.GetOneVoyage((int)id);
                    if (v != null)
                    {
                        return(View("editVoyage", v));
                    }
                    var vo = new Voyage {
                        DepartTime = DateTime.Now, ArrivalTime = DateTime.Now.AddHours(1)
                    };
                    return(View(vo));
                }
                else
                {
                    var vo = new Voyage {
                        DepartTime = DateTime.Now, ArrivalTime = DateTime.Now.AddHours(1)
                    };
                    return(View(vo));
                }
            }
        }
Beispiel #6
0
        public ActionResult EditVoyage(Entity.Voyage value)
        {
            ViewBag.Title         = "Edit Voyage";
            ViewBag.postInfo      = "L'enregistrement voyage saved successfuly";
            ViewBag.postInfoClass = "alert-success";
            var vehiculeTypes = new SelectList(new List <Object>
            {
                new { Id = "BUS", Name = "Bus" },
                new { Id = "TRAIN", Name = "Train" },
                new { Id = "AVION", Name = "Avion" },
                new { Id = "TAXI", Name = "Taxi" },
            }, "Id", "Name");

            ViewBag.vehiculeTypes = vehiculeTypes;
            Console.WriteLine(value.Id + ";" + value.DepartId + ";" + value.ArrivalId + ";" + value.DepartTime + ";" + value.ArrivalTime + ";" + value.CompanyId);
            using (var dao = new Dao.Dao())
            {
                var listCompanies = dao.CompaniesList();
                ViewBag.listVilles    = new SelectList(dao.VillesList(), "Id", "Name");
                ViewBag.listCompanies = new SelectList(listCompanies, "Id", "Name");
                var listVehicules = listCompanies.Count > 0
                    ? dao.VehiculesListFor(listCompanies[0].Id)
                    : new List <Vehicule>();
                ViewBag.listVehicules = new SelectList(listVehicules, "Id", "Name");
                if (!ModelState.IsValid)
                {
                    Console.WriteLine("Error, model non valid");
                    ViewBag.Error = "Model non valid";
                    return(View(value));
                }
                if (value.ArrivalTime < value.DepartTime)
                {
                    ModelState.AddModelError("DeparTime", "La date d'arrivé ne peut être superieur à la date de depart");
                    return(View(value));
                }
                dao.UpdateVoyage(value);
                return(View("Saved"));
            }
        }