コード例 #1
0
        public ActionResult DeleteConfirmed(int id)
        {
            Augementation augementation = db.Augementations.Find(id);

            db.Augementations.Remove(augementation);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
        public ActionResult DeleteAug(int id)
        {
            Augementation augementation = db.Augementations.Find(id);
            int           codec         = augementation.CodeContrat.Value;

            db.Augementations.Remove(augementation);
            db.SaveChanges();
            return(RedirectToAction("DetailsContrat", new { id = codec }));
        }
コード例 #3
0
 public ActionResult Edit([Bind(Include = "idAug,dateAug,pcAug,CodeContrat,CodePers,CodeLocal")] Augementation augementation)
 {
     if (ModelState.IsValid)
     {
         db.Entry(augementation).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CodePers = new SelectList(db.ContratLocations, "CodePers", "commentaire", augementation.CodePers);
     return(View(augementation));
 }
コード例 #4
0
        // GET: Augementations/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Augementation augementation = db.Augementations.Find(id);

            if (augementation == null)
            {
                return(HttpNotFound());
            }
            return(View(augementation));
        }
コード例 #5
0
        public ActionResult CreateAug([Bind(Include = "idAug,CodePers,CodeLocal,CodeContrat,dateAug,pcAug")] Augementation augementation)
        {
            //if (ModelState.IsValid)
            //{
            ContratLocation contrat = db.ContratLocations.Where(c => c.CodeContrat == augementation.CodeContrat).First();

            if (!string.IsNullOrEmpty(contrat.DateFinContrat.ToString()))
            {
                if (augementation.dateAug > contrat.DateJuissance && augementation.dateAug < contrat.DateFinContrat)
                {
                    if (augementation.pcAug.Value > db.Augementations.Where(c => c.CodeContrat == augementation.CodeContrat).Max(c => c.pcAug))
                    {
                        db.Augementations.Add(augementation);

                        db.SaveChanges();
                    }
                    return(RedirectToAction("Details", new { id = augementation.CodeContrat }));
                }
                else
                {
                    //ModelState.AddModelError("dateAugErr", "La date est invalide");

                    return(RedirectToAction("Details", new { id = augementation.CodeContrat }));
                }
            }
            else if (augementation.dateAug > contrat.DateJuissance)
            {
                if (contrat.Augementations.Count() > 0)
                {
                    if (augementation.pcAug.Value > db.Augementations.Where(c => c.CodeContrat == augementation.CodeContrat).Max(c => c.pcAug) && augementation.dateAug.Value > db.Augementations.Where(c => c.CodeContrat == augementation.CodeContrat).Max(c => c.dateAug))
                    {
                        db.Augementations.Add(augementation);

                        db.SaveChanges();
                    }
                }
                else
                {
                    db.Augementations.Add(augementation);

                    db.SaveChanges();
                }

                return(RedirectToAction("Details", new { id = augementation.CodeContrat }));
            }
            //}

            ViewBag.CodePers = new SelectList(db.ContratLocations, "CodePers", "commentaire", augementation.CodePers);
            return(View(augementation));
        }
コード例 #6
0
        // GET: Augementations/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Augementation augementation = db.Augementations.Find(id);

            if (augementation == null)
            {
                return(HttpNotFound());
            }
            ViewBag.CodePers = new SelectList(db.ContratLocations, "CodePers", "commentaire", augementation.CodePers);
            return(View(augementation));
        }
        public ActionResult CreateAug([Bind(Include = "idAug,CodePers,CodeLocal,CodeContrat,dateAug,pcAug")] Augementation augementation)
        {
            if (ModelState.IsValid)
            {
                ContratLocation contrat = db.ContratLocations.Where(c => c.CodeContrat == augementation.CodeContrat).First();
                if (augementation.dateAug > contrat.DateJuissance && augementation.dateAug < contrat.DateFinContrat)
                {
                    db.Augementations.Add(augementation);

                    db.SaveChanges();

                    return(RedirectToAction("DetailsContrat", new { id = augementation.CodeContrat }));
                }
                else
                {
                    ModelState.AddModelError("", "La date est invalide");

                    return(RedirectToAction("DetailsContrat", new { id = augementation.CodeContrat }));
                }
            }

            ViewBag.CodePers = new SelectList(db.ContratLocations, "CodePers", "commentaire", augementation.CodePers);
            return(View(augementation));
        }