示例#1
0
        public ActionResult Create(Contact contact)
        {
            if (ModelState.IsValid)
            {
                if (Request.IsAjaxRequest())
                {
                    db.Contacts.Add(contact);
                    db.SaveChanges();
                    return null;
                }
                db.Contacts.Add(contact);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name", contact.OrganizationId);
            return View(contact);
        }
        public JsonResult _CreateContact(Contact contact)
        {
            if (ModelState.IsValid)
            {
                if (Request.IsAjaxRequest())
                {
                    db.Contacts.Add(contact);
                    db.SaveChanges();

                    return Json(contact, JsonRequestBehavior.AllowGet);
                }
                db.Contacts.Add(contact);
                db.SaveChanges();
                return Json(contact, JsonRequestBehavior.AllowGet);
            }

            ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name");
            return Json("blerrggg");
        }
示例#3
0
        public ActionResult _CreateContact(Contact contact)
        {
            if (ModelState.IsValid)
            {
                db.Contacts.Add(contact);
                db.SaveChanges();
                return View("Evaluation");
            }

            ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name");
            return View();
        }
示例#4
0
 public ActionResult Edit(Contact contact)
 {
     if (ModelState.IsValid)
     {
         db.Entry(contact).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.OrganizationId = new SelectList(db.Organizations, "Id", "Name", contact.OrganizationId);
     return View(contact);
 }