public ActionResult Create(FormCollection collection) { try { var account = new Account(); account.AccountName = collection["AccountName"]; account.DisplayName = collection["DisplayName"]; account.State = (int)AccountState.Active; Context.Add(account); Context.Commit(); return RedirectToAction("Index"); } catch { return View(); } }
/// <summary> /// Create a new Account object. /// </summary> /// <param name="id">Initial value of the Id property.</param> /// <param name="accountName">Initial value of the AccountName property.</param> /// <param name="displayName">Initial value of the DisplayName property.</param> public static Account CreateAccount(global::System.Int64 id, global::System.String accountName, global::System.String displayName) { Account account = new Account(); account.Id = id; account.AccountName = accountName; account.DisplayName = displayName; return account; }
/// <summary> /// Deprecated Method for adding a new object to the Accounts EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToAccounts(Account account) { base.AddObject("Accounts", account); }