/// <summary> /// Action that will grab a specific error from the API and also the comments and users associated with that /// error /// </summary> /// <param name="id">Error ID</param> /// <param name="context">Syntacs DbContext</param> /// <param name="error">Error</param> /// <returns>ErrorResultViewModel</returns> public static async Task <ErrorResultViewModel> ViewDetailsError(int id, SyntacsDbContext context, Error error) { ErrorResultViewModel ervm = new ErrorResultViewModel { Error = error, Users = await context.Users.ToListAsync(), Comments = await context.Comments.Where(c => c.ErrExampleID == id) .Join(context.Users, c => c.UserID, u => u.ID, (comment, user) => new Comment { Alias = user.Alias, UserID = user.ID, ID = comment.ID, CommentBody = comment.CommentBody, ErrExampleID = comment.ErrExampleID, UpVote = comment.UpVote }) .ToListAsync() }; ervm.CodeFormat = CodeFormatter(ervm.Error); return(ervm); }
/// <summary> /// Action that takes in a list of all errors /// </summary> /// <param name="errors">List of Errors from the API</param> /// <returns>ErrorResultViewModel</returns> public static ErrorResultViewModel AllDetails(List <Error> errors) { ErrorResultViewModel ervm = new ErrorResultViewModel { Errors = errors }; return(ervm); }
/// <summary> /// Method used to view the current Top Rated Error /// </summary> /// <param name="error">Error to pass in</param> /// <returns></returns> public static ErrorResultViewModel ViewTopError(Error error) { ErrorResultViewModel ervm = new ErrorResultViewModel { Error = error, CodeFormat = error.CodeExample.Split("\n") }; return(ervm); }