diff --git a/src/dotnet/APIView/APIViewWeb/Controllers/UsageSampleController.cs b/src/dotnet/APIView/APIViewWeb/Controllers/UsageSampleController.cs deleted file mode 100644 index f4b78913749e..000000000000 --- a/src/dotnet/APIView/APIViewWeb/Controllers/UsageSampleController.cs +++ /dev/null @@ -1,47 +0,0 @@ -using System; -using System.Threading.Tasks; -using APIViewWeb.Models; -using APIViewWeb.Repositories; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Mvc; - -namespace APIViewWeb.Controllers -{ - [Authorize("RequireOrganization")] - public class UsageSampleController: Controller - { - private readonly UsageSampleManager _sampleManager; - private readonly ReviewManager _reviewManager; - - public UsageSampleController(UsageSampleManager sampleManager, ReviewManager reviewManager) - { - _sampleManager = sampleManager; - _reviewManager = reviewManager; - } - - [HttpPost] - public async Task Add(string reviewId, string sampleText) - { - await _sampleManager.CreateReviewUsageSampleAsync(reviewId, sampleText); - var review = await _reviewManager.GetReviewAsync(User, reviewId); - - } - - //[HttpPost] - //public async Task Update(string reviewId, string commentId, string commentText) - //{ - // var comment = await _commentsManager.UpdateCommentAsync(User, reviewId, commentId, commentText); - - // return await CommentPartialAsync(reviewId, comment.ElementId); - //} - - //[HttpPost] - //public async Task Delete(string reviewId, string commentId, string elementId) - //{ - // await _commentsManager.DeleteCommentAsync(User, reviewId, commentId); - - // return await CommentPartialAsync(reviewId, elementId); - //} - - } -} diff --git a/src/dotnet/APIView/APIViewWeb/Models/UsageSampleFileModel.cs b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleFileModel.cs new file mode 100644 index 000000000000..7da5007b1d15 --- /dev/null +++ b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleFileModel.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; + +namespace APIViewWeb +{ + public class UsageSampleFileModel + { + public string UsageSampleFileId { get; set; } = IdHelper.GenerateId(); + + public DateTime CreationDate { get; set; } = DateTime.Now; + } +} diff --git a/src/dotnet/APIView/APIViewWeb/Models/UsageSampleModel.cs b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleModel.cs index 9e0d2e006920..55015b266b08 100644 --- a/src/dotnet/APIView/APIViewWeb/Models/UsageSampleModel.cs +++ b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleModel.cs @@ -10,29 +10,14 @@ namespace APIViewWeb public class UsageSampleModel { [JsonProperty("id")] - public string SampleId { get; set; } + public string SampleId { get; set; } = IdHelper.GenerateId(); + public string ReviewId { get; set; } + public string UsageSampleFileId { get; set; } - public string SampleContent { get; set; } - - public string UsageSampleFileId { get; set; } = IdHelper.GenerateId(); - - public UsageSampleModel(string revId, Stream sampleContent) - { - SampleId = revId; - if (sampleContent != null) - { - String content = sampleContent.ToString(); // Write to file later. - SampleContent = parseMDtoHTML(content); - } - else - { - SampleContent = null; - } - } - - private string parseMDtoHTML(string md) + public UsageSampleModel(string revId, string fileId) { - return md; + ReviewId = revId; + UsageSampleFileId = fileId; } } diff --git a/src/dotnet/APIView/APIViewWeb/Models/UsageSampleUploadModel.cs b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleUploadModel.cs new file mode 100644 index 000000000000..b36ce2f363b3 --- /dev/null +++ b/src/dotnet/APIView/APIViewWeb/Models/UsageSampleUploadModel.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; + +namespace APIViewWeb.Pages.Assemblies +{ + public class UsageSampleUploadModel + { + [BindProperty] + public string sampleString { get; set; } + + [BindProperty] + public string ReviewId { get; set; } + + [BindProperty] + public IFormFile File { get; set; } + } +} diff --git a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Samples.cshtml b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Samples.cshtml index 97745eab66c1..b72b1f0f5470 100644 --- a/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Samples.cshtml +++ b/src/dotnet/APIView/APIViewWeb/Pages/Assemblies/Samples.cshtml @@ -8,7 +8,7 @@
- @if (Model.Sample.SampleContent == null) + @if (Model.Sample == null || Model.SampleContent == "No Sample.") {
There is no sample present in the review.
@@ -17,7 +17,15 @@ else {
-

There is a sample but you haven't coded this yet

+ +
+ + + +
+
+
+

@Model.SampleContent

}
@@ -53,21 +61,22 @@
-
- +
- +
+
+
- - + +