public virtual ActionResult Create(UserGroup tocreate) { if (ModelState.IsValid) { try { var group = new UserGroup(); UpdateModel(group); db.AddToUserGroups(group); db.SaveChanges(); return RedirectToAction("Index"); } catch { return View(tocreate); } } ModelState.AddModelError("", "不能创建,请检查是否输入完整"); return View(tocreate); }
/// <summary> /// Create a new UserGroup object. /// </summary> /// <param name="groupID">Initial value of the GroupID property.</param> public static UserGroup CreateUserGroup(global::System.Int32 groupID) { UserGroup userGroup = new UserGroup(); userGroup.GroupID = groupID; return userGroup; }
/// <summary> /// Deprecated Method for adding a new object to the UserGroups EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUserGroups(UserGroup userGroup) { base.AddObject("UserGroups", userGroup); }