public virtual async Task <ActionResult> Editor(RedirectModel model, bool?saveAndContinue) { if (!ModelState.IsValid) { return(View(model)); } var record = _redirectModelFactory.PrepareTblRedirects(model); var recordId = model.Id; try { if (model.Id == null) { //Add new record recordId = await _redirectsService.AddAsync(record); } else { //Edit record await _redirectsService.UpdateAsync(record); } } catch (Exception e) { var errorCode = ErrorLog.GetDefault(System.Web.HttpContext.Current).Log(new Error(e, System.Web.HttpContext.Current)); ModelState.AddModelError("", string.Format(_localizationService.GetResource("ErrorOnOperation"), e.Message, errorCode)); return(View(model)); } if (saveAndContinue != null && saveAndContinue.Value) { return(RedirectToAction("Editor", "ManageRedirects", new { id = recordId })); } return(Content(@"<script language='javascript' type='text/javascript'> window.close(); window.opener.refreshRedirectsGrid(); </script>")); }