public async Task <ActionResult> UpdateApplication(AppCreateViewModel model) { var createAppModel = new Application { AppName = model.AppName, AppKey = model.AppKey, Id = model.Id, DefaultRetainPeriodDays = model.DefaultRetainPeriodDays, Enabled = model.Enabled, MaxErrors = model.MaxErrors, MaxFatalErrors = model.MaxFatalErrors, MaxWarnings = model.MaxWarnings }; try { validateCreateAppViewModel(model); Application newApp = await ApplicationBusiness.UpdateApplicationAsync(createAppModel); if (newApp == null) { throw new ApplicationException("Could not create the application!"); } return(RedirectToAction("Index", "Application")); } catch (Exception ex) { Logger.LogError(ex); ModelState.AddModelError("CustomError", ex); return(View("CreateApplication", model)); } }
public ActionResult CreateApplication() { var model = new AppCreateViewModel { IsEditMode = false, Enabled = true, DefaultRetainPeriodDays = Util.GetRetentionDays(), MaxErrors = 100, MaxFatalErrors = 100, MaxWarnings = 100 }; return(View(model)); }
private void validateCreateAppViewModel(AppCreateViewModel model) { if (model.DefaultRetainPeriodDays == 0) { throw new ArgumentException("Retention period must be between 1 and 30 days"); } if (model.MaxFatalErrors == 0) { throw new ArgumentException("Max. number of fatal errors must be bigger than 1. Suggested value is 100"); } if (model.MaxErrors == 0) { throw new ArgumentException("Max. number of errors must be bigger than 1. Suggested value is 100"); } if (model.MaxWarnings == 0) { throw new ArgumentException("Max. number of warnings must be bigger than 1. Suggested value is 100"); } }
public async Task <ActionResult> UpdateApplication(long Id) { Application app = await ApplicationBusiness.GetByIdAsync(Id); if (app != null && !string.IsNullOrEmpty(app.AppKey)) { var model = new AppCreateViewModel { IsEditMode = true, Enabled = app.Enabled, DefaultRetainPeriodDays = app.DefaultRetainPeriodDays, MaxErrors = app.MaxErrors, MaxFatalErrors = app.MaxFatalErrors, MaxWarnings = app.MaxWarnings, AppName = app.AppName, AppKey = app.AppKey, Id = Id }; return(View("CreateApplication", model)); } return(new HttpNotFoundResult("The application that you requests could not be found.")); }