示例#1
0
        public ActionResult Create(Ao ao)
        {
            //User.Identity.Name
            ao.DateCreation = DateTime.Now;
            ao.UtilisateurId = db.Utilisateurs.Where(u => u.Matricule == User.Identity.Name).First().Id;

            if (ModelState.IsValid)
            {
                db.Aos.Add(ao);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.ContactId = new SelectList(db.Contacts, "Id", "Nom", ao.ContactId);
            ViewBag.FamilleId = new SelectList(db.Familles, "Id", "Libelle", ao.FamilleId);
            ViewBag.StatutAoId = new SelectList(db.StatutAos, "Id", "Libelle", ao.StatutAoId);
            ViewBag.TypeConsultationId = new SelectList(db.TypeConsultations, "Id", "Libelle", ao.TypeConsultationId);
            ViewBag.UtilisateurId = new SelectList(db.Utilisateurs, "Id", "Matricule", ao.UtilisateurId);
            return View(ao);
        }
示例#2
0
        public ActionResult Edit(Ao ao)
        {
            if (ModelState.IsValid)
            {
                db.Entry(ao).State = EntityState.Modified;
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            //ViewBag.ClientId = new SelectList(db.Clients, "Id", "Libelle", ao.Contact.Client.Id);
            //ViewBag.SegmentId = new SelectList(db.Segments, "Id", "Libelle", ao.Famille.Segment.Id);
            ViewBag.ContactId = new SelectList(db.Contacts, "Id", "Nom", ao.ContactId);
            ViewBag.FamilleId = new SelectList(db.Familles, "Id", "Libelle", ao.FamilleId);
            ViewBag.StatutAoId = new SelectList(db.StatutAos, "Id", "Libelle", ao.StatutAoId);
            ViewBag.TypeConsultationId = new SelectList(db.TypeConsultations, "Id", "Libelle", ao.TypeConsultationId);


            return View(ao);
        }