Exemple #1
0
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation($"{nameof(ToDoCommentAdd)} processed a request.");

            string toDoId = req.Query["toDoId"];

            if (string.IsNullOrWhiteSpace(toDoId))
            {
                throw new ArgumentNullException(nameof(toDoId));
            }

            var toDoCommentAddOptions =
                await req.Body.DeserializeAsync <ToDoCommentAddOptions>();

            var toDoCommentEntity =
                new ToDoCommentEntity
            {
                Body      = toDoCommentAddOptions.Body,
                CreatedOn = DateTime.UtcNow
            };

            await _toDoCommentEntityDataStore.AddAsync(
                toDoId,
                toDoCommentEntity);

            return(new CreatedResult("", new ToDoComment(toDoCommentEntity)));
        }
Exemple #2
0
 public ToDoComment(
     ToDoCommentEntity toDoCommentEntity)
 {
     this.Id        = toDoCommentEntity.RowKey;
     this.ToDoId    = toDoCommentEntity.PartitionKey;
     this.Body      = toDoCommentEntity.Body;
     this.CreatedOn = toDoCommentEntity.CreatedOn;
 }
Exemple #3
0
 public ToDoComment(
     ToDoCommentEntity toDoCommentEntity)
 {
     this.Id        = toDoCommentEntity.Id;
     this.ToDoId    = toDoCommentEntity.ToDoId;
     this.Body      = toDoCommentEntity.Body;
     this.CreatedOn = toDoCommentEntity.CreatedOn;
 }
Exemple #4
0
        public static ToDoCommentEntity GenerateToDoCommentEntity(
            this Faker faker,
            string toDoId)
        {
            var id =
                Guid.NewGuid().ToString();

            var toDoCommentEntity =
                new ToDoCommentEntity
            {
                Id        = id,
                ToDoId    = toDoId,
                Body      = faker.Lorem.Paragraph(1),
                CreatedOn = faker.Date.Recent()
            };

            return(toDoCommentEntity);
        }