title: Closing a modal window after httppost
body: <p>I have a view that displays a list of user roles (e.g., administrator, operator, etc) and an "Add" button that pops up a modal window, allowing the user to add a new role.</p>
  
  <p>In my controller, I have this as my HttpPost method</p>
  
  <pre><code>    [HttpPost]
      public ActionResult Create(RoleModel model)
      {
  
          if (ModelState.IsValid)
          {
              var role = new RoleDto
                  {
                      Name = model.Name,
                      Description = model.Description
                  };
  
              var roleAdded = _rolePermissionsRepository.AddRole(role);
              if (roleAdded != null)
              {
                  //CLOSE WINDOW
              }
              else
              {
                  //PRINT ERROR MSG TO WINDOW
              }
          }
          return View();
      }
  </code></pre>
  
  <p>If the add to the DB is successful,  I would like to close the modal window, and then refresh the list on my main index page. </p>
  
  <p>If there's some error while persisting to the DB, the modal window should remain open, and show some error.</p>
  
  <p>How do I achieve that?</p>
  
  <p>This is what I'm using on my Index page to pop up the window</p>
  
  <pre><code>    $("#open").click(function (e) {
          wnd.center();
          wnd.open();
      });
  </code></pre>