protected virtual void ShowError(ViewModelResult result) { if (LblError == null) { return; } if (result == null || result is SuccessResult) { LblError.Text = ""; LblError.IsVisible = false; } else { LblError.IsVisible = true; if (result is FieldErrorResult) { LblError.Text = ((FieldErrorResult)result).Reason; } else { LblError.Text = result.Message; } } }
// GET: Articles/Details/5 public ActionResult Details(int?id) { ViewModelResult model = new ViewModelResult(); try { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } CommentList cmtList = new CommentList(); var comments = cmtList.getListComment(id); ArticleList art = new ArticleList(); var details = art.getDetailArticle(id); model = new ViewModelResult { articleDetail = details, listComment = comments }; } catch (Exception e) { CommonUse.WriteLogError(e); } return(View(model)); }
public ActionResult ResultIncrement(ViewModelAdd viewModel) { if (!ModelState.IsValid) { return(View("Increment")); } ViewModelResult result = new ViewModelResult { Result = ++viewModel.Number }; return(View(result)); }
/// <summary> /// Processes the successful response asynchronously. /// </summary> /// <param name="response">The response.</param> /// <returns>A task that represents the asynchronous operation.</returns> protected virtual async Task <EdgeDefinition> ProcessSuccessfulResponseAsync(ViewModelResult response) { if (response.IsAction(DisplayActions.Create)) { return(this.Create); } if (response.IsAction(DisplayActions.Back)) { return(this.Back); } if (response.IsAction(DisplayActions.Delete)) { if (response.Ids != null && response.Ids.Count > 0) { this.MultiSelectIds = response.Ids; return(this.Delete); } } if (response.IsAction(DisplayActions.Next)) { var singleId = response.Ids?.FirstOrDefault() ?? 0; if (singleId > 0) { this.SingleSelectId = singleId; return(this.Edit); } } if (response.IsAction(DisplayActions.AddToDashboard)) { await this.dashboard.AddComponentAsync(this.DashboardComponentName, this.DashboardComponentConfiguration, this.DashboardComponentOptions); return(null); } return(null); }
void Field_Validated(object sender, ViewModelResult e) { ShowError(e); }
protected override async Task <EdgeDefinition> ProcessSuccessfulResponseAsync(ViewModelResult <EditViewModel> response, Models.SearchResult dto) { if (response.IsAction(DisplayActions.CatchEmAll_UpdateFromSource)) { return(this.UpdateFromSource); } if (response.IsAction(DisplayActions.AddToDashboard)) { using (var context = this.dataAccess.GetContext()) { var entity = await context.Tracking <DAL.Entities.SearchResult>() .Where(e => e.Id == this.Id) .SingleAsync(); entity.Favorite = !entity.Favorite; await context.SaveChangesAsync(); } return(this.Saved); // forces reload of the dto } if (response.IsAction(DisplayActions.Delete)) { using (var context = this.dataAccess.GetContext()) { var entity = await context.Tracking <DAL.Entities.SearchResult>() .Where(e => e.Id == this.Id) .SingleAsync(); entity.Hidden = true; await context.SaveChangesAsync(); } return(this.Back); } return(await base.ProcessSuccessfulResponseAsync(response, dto)); }
protected virtual void ShowError(ViewModelResult result) { }
protected override async Task <EdgeDefinition> ProcessSuccessfulResponseAsync(ViewModelResult response) { if (response.IsAction(DisplayActions.CatchEmAll_UpdateFromSource)) { return(this.UpdateFromSource); } if (response.IsAction(DisplayActions.CatchEmAll_ShowArchive)) { return(this.ShowArchive); } if (response.IsAction(DisplayActions.CatchEmAll_EditQuery)) { return(this.EditQuery); } return(await base.ProcessSuccessfulResponseAsync(response)); }
protected override async Task <EdgeDefinition> ProcessSuccessfulResponseAsync(ViewModelResult response) { if (response.IsAction(DisplayActions.CatchEmAll_ShowAllExecutions)) { this.Mode = ExecutionDisplayMode.ShowAll; } if (response.IsAction(DisplayActions.CatchEmAll_ShowFailedExecutions)) { this.Mode = ExecutionDisplayMode.ShowFailed; } if (response.IsAction(DisplayActions.CatchEmAll_ShowRunningExecutions)) { this.Mode = ExecutionDisplayMode.ShowRunning; } return(await base.ProcessSuccessfulResponseAsync(response)); }
protected override async Task <EdgeDefinition> ProcessSuccessfulResponseAsync(ViewModelResult response) { if (response.IsAction(DisplayActions.CatchEmAll_ImportExisting)) { return(this.ImportExisting); } return(await base.ProcessSuccessfulResponseAsync(response)); }