public ActionResult DeleteConfirmed(int id)
        {
            LocationDeVoiture locationDeVoiture = db.LocationDeVoitures.Find(id);

            db.LocationDeVoitures.Remove(locationDeVoiture);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "idlocation,dateReservation,datePaiment,Montant,idCli,idV")] LocationDeVoiture locationDeVoiture)
 {
     if (ModelState.IsValid)
     {
         db.Entry(locationDeVoiture).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(locationDeVoiture));
 }
        public ActionResult Create([Bind(Include = "idlocation,dateReservation,datePaiment,Montant,idCli,idV")] LocationDeVoiture locationDeVoiture)
        {
            if (ModelState.IsValid)
            {
                db.LocationDeVoitures.Add(locationDeVoiture);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(locationDeVoiture));
        }
        // GET: LocationDeVoitures/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            LocationDeVoiture locationDeVoiture = db.LocationDeVoitures.Find(id);

            if (locationDeVoiture == null)
            {
                return(HttpNotFound());
            }
            return(View(locationDeVoiture));
        }
Exemplo n.º 5
0
        public ActionResult Setdata(int km)
        {
            string  AE = Session["idV"].ToString();
            string  B  = Session["idc"].ToString();
            Voiture V  = db.Voitures.Find(int.Parse(AE));
            Client  c  = db.Clients.Find(int.Parse(B));
            Admin   A  = new Admin();
            int     H  = (int)V.PrixKm;

            LocationDeVoiture L = new LocationDeVoiture()
            {
                dateReservation = DateTime.Now,
                datePaiment     = DateTime.Now,
                Montant         = H * km,
                idCli           = c.Id_cli,
                idV             = V.Vmatricule,
                __  = null,
                _   = null,
                ___ = null
            };

            if (ModelState.IsValid)
            {
                try
                {
                    db.LocationDeVoitures.Add(L);
                    db.SaveChanges();
                    return(RedirectToAction("Index", "Home"));
                }
                catch (DbEntityValidationException e)
                {
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                    }
                    throw;
                }
            }
            return(View());
        }