Example #1
0
        public virtual async Task <ActionResult> Create(AddRoleViewModel viewModel)
        {
            if (_roleManager.CheckForExisByName(viewModel.Name, null))
            {
                this.AddErrors("Name", "این گروه  قبلا در سیستم ثبت شده است");
            }

            if (!ModelState.IsValid)
            {
                return(new JsonNetResult
                {
                    Data =
                        new
                    {
                        success = false,
                        View = this.RenderPartialViewToString(MVC.Role.Views._Create, viewModel)
                    }
                });
            }
            var newRole = await _roleManager.AddRole(viewModel);

            return(new JsonNetResult
            {
                Data =
                    new
                {
                    success = true,
                    View = this.RenderPartialViewToString(MVC.Role.Views._RoleItem, newRole)
                }
            });
        }