Example #1
0
 public ActionResult EditRole(Role model)
 {
     if (model != null)
     {
         userService.UpdateRole(model);
         return Json(true, JsonRequestBehavior.AllowGet);
     }
     return Json(false, JsonRequestBehavior.AllowGet);
 }
Example #2
0
 public ActionResult CreateRole(Role model)
 {
     if (model != null)
     {
         model.Id = Guid.NewGuid().ToString();
         userService.CreateRole(model);
         return Json(true, JsonRequestBehavior.AllowGet);
     }
     return Json(false, JsonRequestBehavior.AllowGet);
 }
Example #3
0
 /// <summary>
 /// Update role
 /// </summary>
 /// <param name="role"></param>
 public void UpdateRole(Role role)
 {
     role.UserRoles = null;
     roleRepository.Update(role);
 }
Example #4
0
 public void CreateRole(Role role)
 {
     roleRepository.Add(role);
 }
Example #5
0
        /// <summary>
        /// Update a role
        /// </summary>
        /// <param name="role"></param>
        public void DeleteRole(Role role)
        {
            using (var dbContext = new DatabaseContext())
            {

                var rDel = dbContext.Roles.FirstOrDefault(r => r.Id.Equals(role.Id));

                if (rDel != null)
                {
                    dbContext.Roles.Remove(rDel);
                    dbContext.SaveChanges();
                }
            }
        }