// // GET: /Api/Solution/5.json public ActionResult Solution(int id, string format) { if (format != "json") return null; var result = _db.Results.Include(r => r.Solution.Language).Single(r => r.Id == id); var solution = new DTO.Solution { Id = result.Id, Answer = result.Solution.Answer, LanguageId = result.Solution.LanguageId, ProblemId = result.Solution.ProblemId }; return Json(solution, JsonRequestBehavior.AllowGet); }
/// <summary> /// Generates a <see cref="DTO.Thing"/> from the current <see cref="Solution"/> /// </summary> public override DTO.Thing ToDto() { var dto = new DTO.Solution(this.Iid, this.RevisionNumber); dto.Author = this.Author != null ? this.Author.Iid : Guid.Empty; dto.Content = this.Content; dto.CreatedOn = this.CreatedOn; dto.ExcludedDomain.AddRange(this.ExcludedDomain.Select(x => x.Iid)); dto.ExcludedPerson.AddRange(this.ExcludedPerson.Select(x => x.Iid)); dto.LanguageCode = this.LanguageCode; dto.ModifiedOn = this.ModifiedOn; dto.Owner = this.Owner != null ? this.Owner.Iid : Guid.Empty; dto.RevisionNumber = this.RevisionNumber; dto.ThingPreference = this.ThingPreference; dto.IterationContainerId = this.CacheKey.Iteration; dto.RegisterSourceThing(this); this.BuildDtoPartialRoutes(dto); return(dto); }