Exemplo n.º 1
0
 /// <summary>
 /// Map DTO fields to Table fields
 /// </summary>
 /// <param name="opp">Opportunity Info DTO</param>
 /// <returns></returns>
 public static OpportunityInfoEntity ToTableEntity(OpportunityInfo opp)
 {
     return(new OpportunityInfoEntity()
     {
         PartitionKey = "OpportunityInfo",
         RowKey = opp.Id,
         OpportunityId = opp.OpportunityId,
         Domain = opp.Domain,
         Name = opp.Name,
         PrimaryProduct = opp.PrimaryProduct,
         Industry = opp.Industry
     });
 }
Exemplo n.º 2
0
        public static async Task <IActionResult> CreateCreateOpportunityInfo(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "OppInfo")] HttpRequest req,
            [Table(TableName, Connection = "AzureWebJobsStorage")] IAsyncCollector <OpportunityInfoEntity> OpportunityInfoTable,
            ILogger log)
        {
            log.LogInformation("Creating a new Opportunity list item");
            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    input       = JsonConvert.DeserializeObject <OpportunityInfoEntity>(requestBody);

            var opp = new OpportunityInfo()
            {
                OpportunityId  = input.OpportunityId,
                Domain         = input.Domain,
                Name           = input.Name,
                PrimaryProduct = input.PrimaryProduct,
                Industry       = input.Industry,
            };
            await OpportunityInfoTable.AddAsync(Mappings.ToTableEntity(opp));

            return(new OkObjectResult(opp));
        }