public ActionResult Create(Role role) { if (!Authorization.GetAccess(table, HttpContext.User.Identity.Name, admin)) return RedirectToAction("Index", "Home"); if (ModelState.IsValid) { role.ID = Guid.NewGuid(); role.CreatedBy = Guid.Parse(Session["userid"].ToString()); role.CreatedOn = DateTime.Now; db.Roles.AddObject(role); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.CreatedBy = new SelectList(db.Users, "ID", "UserName", role.CreatedBy); ViewBag.ModifiedBy = new SelectList(db.Users, "ID", "UserName", role.ModifiedBy); return View(role); }
/// <summary> /// Create a new Role object. /// </summary> /// <param name="id">Initial value of the ID property.</param> /// <param name="role1">Initial value of the Role1 property.</param> public static Role CreateRole(global::System.Guid id, global::System.String role1) { Role role = new Role(); role.ID = id; role.Role1 = role1; return role; }
/// <summary> /// Deprecated Method for adding a new object to the Roles EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToRoles(Role role) { base.AddObject("Roles", role); }