Пример #1
0
 public static ExperienceEntity ExperienceTableEntity(this ExperienceModel experience)
 {
     return(new ExperienceEntity
     {
         PartitionKey = "experience",
         RowKey = experience.expId,
         expCreatedDate = experience.expCreatedDate,
         expCompanyLogoUri = experience.expCompanyLogoUri,
         expEmployeeTitle = experience.expEmployeeTitle,
         expCompany = experience.expCompany,
         expLocation = experience.expLocation,
         expCurrentWorkRole = experience.expCurrentWorkRole,
         expStartDate = experience.expStartDate,
         expEndDate = experience.expEndDate,
         expWorkSubject = experience.expWorkSubject,
         expWorkDescription = experience.expWorkDescription,
         expWorkLinks = experience.expWorkLinks
     });
 }
Пример #2
0
        public static async Task <IActionResult> CreateExperience(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = "experience")] HttpRequest req,
            [Table("aramizexperience", Connection = "AzureWebJobsStorage")] IAsyncCollector <ExperienceEntity> exeperinceTable,
            ILogger log)
        {
            log.LogInformation("Creating new aramiz experience entity");

            ClaimsPrincipal principal;

            AuthenticationHeaderValue.TryParse(req.Headers[HeaderNames.Authorization], out var authHeader);
            if ((principal = await Security.ValidateTokenAsync(authHeader)) == null)
            {
                return(new UnauthorizedResult());
            }

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            var    input       = JsonConvert.DeserializeObject <ExperienceCreateModel>(requestBody);

            var experienceEntity = new ExperienceModel
            {
                expEmployeeTitle   = input.expEmployeeTitle,
                expCompanyLogoUri  = input.expCompanyLogoUri,
                expCompany         = input.expCompany,
                expLocation        = input.expLocation,
                expCurrentWorkRole = input.expCurrentWorkRole,
                expStartDate       = input.expStartDate,
                expEndDate         = input.expEndDate,
                expWorkSubject     = input.expWorkSubject,
                expWorkDescription = input.expWorkDescription,
                expWorkLinks       = input.expWorkLinks
            };

            await exeperinceTable.AddAsync(experienceEntity.ExperienceTableEntity());

            return(new OkObjectResult(experienceEntity));
        }