public async Task <ActionResult> ImportSettings(HttpPostedFileBase file) { ActionResult result = RedirectToAction("Index"); try { if (file == null) { return(result.Warning("Error on importing configs")); } await Store.ImportSettings(file.InputStream); Store.Store(Conf.Issue); Store.Store(Conf.Defect); Store.Store(Conf.Mail); return(result .Success("Configs imported successfully")); } catch (Exception e) { return(result .Error("Error on import settings: " + e.Message)); } }
private void OnRenameFilesButtonClick(object sender, RoutedEventArgs e) { HandleResult(ok => { return(string.IsNullOrWhiteSpace(_context.ViewModel.Template) ? ActionResult.Error("Template is empty, nothing to rename") : _context.RenameFiles()); }); }
public override async Task <ActionResult <LanguageDto> > Handle(GetLanguageCommand command) { var language = await _getLanguageQuery.Query(command); if (language == null) { ActionResult <LanguageDto> .Error(); } var languageDto = _mapper.Map <LanguageDto>(language); return(ActionResult <LanguageDto> .Ok(languageDto)); }
public override async Task <ActionResult <OptionDto> > Handle(GetSystemSettingCommand command) { var systemSettingQuery = await _getSystemSettingQuery.Query(command); if (systemSettingQuery == null) { ActionResult <OptionDto> .Error(); } var inputFormDto = _mapper.Map <OptionDto>(systemSettingQuery); return(ActionResult <OptionDto> .Ok(inputFormDto)); }
public override async Task <ActionResult <InputFormDto> > Handle(GetInputFormCommand command) { var inputFormQuery = await _getInputFormQuery.Query(command); if (inputFormQuery == null) { ActionResult <InputFormDto> .Error(); } var inputFormDto = _mapper.Map <InputFormDto>(inputFormQuery); return(ActionResult <InputFormDto> .Ok(inputFormDto)); }
public ActionResult UpdateMailSettings(MailCredentialsViewModel model) { ActionResult result = RedirectToAction("Mail", model); return(HandleResult("Mail", model, () => { if (Store.Store(model)) { return result .Success("Mail data successfully saved."); } else { return result .Error("Mail data can't be saved."); } })); }
private ActionResult HandleResult(string view, object model, Func <ActionResult> action) { ActionResult result = View(view, model); if (ModelState.IsValid) { try { result = action(); } catch (Exception e) { result = result .Error("Error on handling data: " + e.Message); } } else { result = result.Warning("Data model is not valid..."); } return(result); }
public virtual ActionResult <TResult> Error(Dictionary <string, DetailError> errorMessages) { return(ActionResult <TResult> .Error(errorMessages)); }
public virtual ActionResult <TResult> Error() { return(ActionResult <TResult> .Error()); }
/// <inheritdoc /> public void Result(bool isSuccess, string message, int indent = 0) { var ar = isSuccess ? ActionResult.Success() : ActionResult.Error("See previous log"); Result(ar, message, indent); }
public ActionResult UpdateCredentials(CredentialsViewModel model) { bool hasChanged = false; ActionResult result = View("Credentials", model); if (model.UpdateTfsAccount) { if (Service.IsValidAccount(model.TFSUserName, model.TFSPassword)) { hasChanged = true; Service.Logoff(typeof(IDefectService)); Service.AuthenticateOn(typeof(IDefectService), new NetworkCredential(model.TFSUserName, model.TFSPassword, model.TFSDomainName)); result = result.Success("TFS Account Data Saved"); } else { result.Error("The user name or password provided is incorrect."); } } if (model.UpdateExchangeAccount) { if (Service.IsValidAccount(model.ExchangeUserName, model.ExchangePassword)) { hasChanged = true; Service.Logoff(typeof(IMailService)); Service.AuthenticateOn(typeof(IMailService), new NetworkCredential(model.ExchangeUserName, model.ExchangePassword, model.ExchangeDomainName)); result = result.Success("Exchange Account Data Saved"); } else { result.Error("The user name or password provided is incorrect."); } } if (model.UpdateJiraAccount) { if (Service.IsValidAccount(model.JiraUserName, model.JiraPassword)) { hasChanged = true; Service.Logoff(typeof(IIssueService)); Service.AuthenticateOn(typeof(IIssueService), new NetworkCredential(model.JiraUserName, model.JiraPassword)); result = result.Success("Exchange Account Data Saved"); } else { result.Error("The user name or password provided is incorrect."); } } if (hasChanged) { // save to cookie CookieService.SetData(Request, Response, User.Identity.Name, model); result = RedirectToAction("Credentials", model); } return(result); }