// PUT api/<controller>/5
        public HttpResponseMessage Put(string roleName, RoleViewModel roleViewModel)
        {
            if (!IsAuthorize("write"))
            {
                return Request.CreateResponse(HttpStatusCode.Unauthorized);
            }
            if (ModelState.IsValid && roleName == roleViewModel.UserRole && roleName != string.Empty)
            {
                try
                {
                    Role role = _facade.GetRoleByRoleName(roleName);

                    if (role != null)
                    {
                        role.RoleName = roleViewModel.UserRole;
                        _facade.UpdateRole(role);

                        string roleIdStr = role.RoleId.ToString();
                        List<RolePermission> rolePermissionList = _facade.GetRolePermissionByRoleId(roleIdStr).ToList();
                        foreach (RolePermission item in rolePermissionList)
                        {
                            _facade.UpdateRolePermisson(item);
                        }

                        List<Permission> permissionList = _facade.GetPermissions().ToList();
                        foreach (PermissionViewModel item in roleViewModel.Userpermissions)
                        {
                            Permission permission = permissionList.Where(x => x.PermissionName == item.PermissionName).FirstOrDefault();
                            if (permission != null)
                            {
                                _facade.AddRolePermission(new RolePermission() { RoleId = role.RoleId.ToString(), PermissionId = permission.Id, AllowRead = item.AllowRead, AllowWrite = item.AllowWrite, AllowDelete = item.AllowDelete });
                            }
                        }
                    }
                    else
                        return Request.CreateResponse(HttpStatusCode.BadRequest);
                }
                catch (DbUpdateConcurrencyException)
                {
                    return Request.CreateResponse(HttpStatusCode.NotFound);
                }

                return Request.CreateResponse(HttpStatusCode.OK);
            }
            else
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }
        }
        // POST api/<controller>
        public RolePermissionModel Post(RoleViewModel roleViewModel)
        {
            if (!IsAuthorize("write"))
            {
                return null;
            }

            bool isSuccess = false;
            RolePermissionModel rolePermissionModel = new RolePermissionModel();
            List<RolePermissionViewModel> rolePermissionViewModelList = new List<RolePermissionViewModel>();

            List<Role> allRoles = _facade.GetRoles().ToList();
            List<Permission> permissionList = null;
            Role role = allRoles.Where(x => x.RoleName == roleViewModel.UserRole).FirstOrDefault();
            if (role == null)
            {
                _facade.CreateRole(roleViewModel.UserRole);

                allRoles = _facade.GetRoles().ToList();
                role = allRoles.Where(x => x.RoleName == roleViewModel.UserRole).FirstOrDefault();

                permissionList = _facade.GetPermissions().ToList();
                if (roleViewModel.Userpermissions != null)
                {
                    foreach (PermissionViewModel item in roleViewModel.Userpermissions)
                    {
                        Permission permission = permissionList.Where(x => x.PermissionName == item.PermissionName).FirstOrDefault();
                        if (permission != null)
                        {
                            _facade.AddRolePermission(new RolePermission() { RoleId = role.RoleId.ToString(), PermissionId = permission.Id, AllowRead = item.AllowRead, AllowWrite = item.AllowWrite, AllowDelete = item.AllowDelete });
                        }
                    }
                    isSuccess = true;
                }
                if (isSuccess)
                {
                    rolePermissionViewModelList = GetRolePermissionViewModel();
                }
            }

            rolePermissionModel.PermissionViewModelList = GetPermissionViewModel().ToList<PermissionViewModel>();
            rolePermissionModel.RolePermissionViewModelList = rolePermissionViewModelList;
            return rolePermissionModel;
        }