Exemplo n.º 1
0
 public ActionResult CreateRole(Role role)
 {
     if (ModelState.IsValid)
     {
         role.RoleId = Guid.NewGuid();
         context.Roles.Add(role);
         context.SaveChanges();
         return RedirectToAction("Roles");
     }
     return View(role);
 }
Exemplo n.º 2
0
 public override void CreateRole(string roleName)
 {
     if (!string.IsNullOrEmpty(roleName))
     {
         using (FootyFeudContext Context = new FootyFeudContext())
         {
             Role Role = null;
             Role = Context.Roles.FirstOrDefault(Rl => Rl.RoleName == roleName);
             if (Role == null)
             {
                 Role NewRole = new Role
                 {
                     RoleId = Guid.NewGuid(),
                     RoleName = roleName
                 };
                 Context.Roles.Add(NewRole);
                 Context.SaveChanges();
             }
         }
     }
 }