public ActionResult Create(CorporateAccount corporateaccount) { if (ModelState.IsValid) { db.CorporateAccounts.Add(corporateaccount); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CorporateTypeID = new SelectList(db.CorporateTypes, "CorporateTypeID", "Description", corporateaccount.CorporateTypeID); ViewBag.UserID = new SelectList(db.Users, "UserId", "UserName", corporateaccount.UserID); ViewBag.ValidationStateID = new SelectList(db.ValidationStates, "ValidationStateID", "Description", corporateaccount.ValidationStateID); return View(corporateaccount); }
public ActionResult FillContent() { try { CorporateAccount _corp = new CorporateAccount(); string querystring = Request.Params[0]; _corp = db.CorporateAccounts.Where(e => e.Title == querystring).Single(); CorporateAccountViewModel _cview = new CorporateAccountViewModel { Title = _corp.Title, Address = _corp.Address, Phone1 = _corp.Phone1, Phone2 = _corp.Phone2, ContactPerson = _corp.ContactPerson, CorpEmail = _corp.CorpEmail, CorporateTypeID = _corp.CorporateTypeID.ToString(), UserID = _corp.UserID.ToString(), ValidationStateID = _corp.ValidationStateID.ToString(), is_ok = "ok" }; return Json(_cview, JsonRequestBehavior.AllowGet); } catch { CorporateAccountViewModel _cview = new CorporateAccountViewModel { is_ok = "false" }; return Json(_cview, JsonRequestBehavior.AllowGet); } }