예제 #1
0
 public static ResearchCardTableEntity ToTableEntity(this ResearchCard researchCard)
 {
     return(new ResearchCardTableEntity
     {
         PartitionKey = researchCard.ProjectId,
         RowKey = researchCard.Id,
         CreatedTime = researchCard.CreatedTime,
         Source = researchCard.Source,
         Quote = researchCard.Quote,
         Summary = researchCard.Summary,
         Commentary = researchCard.Commentary,
         Keywords = researchCard.Keywords
     });
 }
예제 #2
0
        public static async Task <IActionResult> CreateCard(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = "{projectId}/cards")] HttpRequest req,
            [Table("cards", Connection = "AzureWebJobsStorage")] IAsyncCollector <ResearchCardTableEntity> researchCardTable,
            ILogger log, string projectId)
        {
            log.LogInformation("Creating a new card.");
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    input       = JsonConvert.DeserializeObject <ResearchCardCreateModel>(requestBody);

            var researchCard = new ResearchCard()
            {
                ProjectId  = projectId,
                Source     = input.Source,
                Quote      = input.Quote,
                Summary    = input.Summary,
                Commentary = input.Commentary,
                Keywords   = input.Keywords
            };
            await researchCardTable.AddAsync(researchCard.ToTableEntity());

            return(new OkObjectResult(researchCard));
        }