Ejemplo n.º 1
0
        public async Task <bool> Create_Async(Post post)
        {
            var cosmosPost = new CosmosPostDto {
                Id = post.Id.ToString(), Name = post.Name
            };
            var response = await _cosmosStore.AddAsync(cosmosPost);

            return(response.IsSuccess);
        }
Ejemplo n.º 2
0
        public async Task <bool> UpdatePost_Async(Post updatePost)
        {
            var cosmoPost = new CosmosPostDto {
                Id = updatePost.Id.ToString(), Name = updatePost.Name
            };
            var response = await _cosmosStore.UpdateAsync(cosmoPost);

            return(response.IsSuccess);
        }
Ejemplo n.º 3
0
        public async Task <bool> CreatePostAsync(Post post)
        {
            var createpost = new CosmosPostDto {
                Id   = Guid.NewGuid().ToString(),
                Name = post.Name,
            };
            var create = await _cosmosStore.AddAsync(createpost);

            return(create.IsSuccess);
        }
Ejemplo n.º 4
0
        public async Task<bool> CreatePostAsync(Post post)
        {
            var cosmosPost = new CosmosPostDto {
                Id = Guid.NewGuid().ToString(),
                Name = post.Name
            };

            var response = await _cosmosStore.AddAsync(cosmosPost);
            post.Id = Guid.Parse(cosmosPost.Id);
            return response.IsSuccess;
        }
Ejemplo n.º 5
0
        public async Task <bool> CreatePostAsync(Post postToCreate)
        {
            var cosmposPost = new CosmosPostDto()
            {
                Id   = Guid.NewGuid().ToString(),
                Name = postToCreate.Name
            };
            var response = await cosmosStore.AddAsync(cosmposPost);

            return(response.IsSuccess);
        }
Ejemplo n.º 6
0
        public async Task <bool> UpdatePostAsync(Post postToUpdate)
        {
            var updatepost = new CosmosPostDto
            {
                Id   = postToUpdate.ID.ToString(),
                Name = postToUpdate.Name
            };
            var update = await _cosmosStore.UpdateAsync(updatepost);

            return(update.IsSuccess);
        }
Ejemplo n.º 7
0
        public async Task<bool> UpdatePostAsync(Post postToUpdate)
        {
            var cosmosPost = new CosmosPostDto
            {
                Id = postToUpdate.Id.ToString(),
                Name = postToUpdate.Name
            };

            var response = await _cosmosStore.UpdateAsync(cosmosPost);

            return response.IsSuccess;
        }
Ejemplo n.º 8
0
        public async Task <bool> UpdateAsync(Post post)
        {
            var cosmosPostDto = new CosmosPostDto
            {
                Id   = post.Id.ToString(),
                Name = post.Name
            };

            var updated = await _cosmosStore.UpdateAsync(cosmosPostDto);

            return(updated.IsSuccess);
        }
Ejemplo n.º 9
0
        public async Task <bool> AddAsync(Post post)
        {
            var cosmosPostDto = new CosmosPostDto
            {
                Id   = Guid.NewGuid().ToString(),
                Name = post.Name
            };

            var added = await _cosmosStore.AddAsync(cosmosPostDto);

            return(added.IsSuccess);
        }
Ejemplo n.º 10
0
        public async Task <bool> AddPost(Post createdPost)
        {
            var cosmosPost = new CosmosPostDto()
            {
                //Id = createdPost.Id.ToString(),
                Id   = Guid.NewGuid().ToString(),
                Name = createdPost.Name
            };
            var response = await cosmosStore.AddAsync(cosmosPost);

            return(response.IsSuccess);
        }
Ejemplo n.º 11
0
        public async Task <bool> CreateAsync(Post newPost)
        {
            var cosmosPostDto = new CosmosPostDto()
            {
                Id   = Guid.NewGuid().ToString(),
                Name = newPost.Name
            };

            var cosmosResponse = await _cosmosStore.AddAsync(cosmosPostDto);


            return(cosmosResponse.IsSuccess);
        }
        public async Task <IActionResult> Create([FromBody] CreatePostRequest postRequest)
        {
            var post = new CosmosPostDto {
                Id = Guid.NewGuid().ToString(), Name = postRequest.Name
            };

            await _cosmosDbService.AddPostAsync(post);

            var baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
            var locationUrl = baseUrl + "/" + ApiRoutes.Posts.Get.Replace("{postId}", post.Id.ToString());

            var response = new PostResponse {
                Id = Guid.Parse(post.Id)
            };

            return(Created(locationUrl, response));
        }
Ejemplo n.º 13
0
        public async Task <bool> UpdatePostAsync(Post postToUpdate)
        {
            var post = await cosmosStore.FindAsync(postToUpdate.Id.ToString());

            if (post == null)
            {
                return(false);
            }

            var cosmposPost = new CosmosPostDto()
            {
                Id   = postToUpdate.Id.ToString(),
                Name = postToUpdate.Name
            };

            var response = await cosmosStore.UpdateAsync(cosmposPost);

            return(response.IsSuccess);
        }
 public async Task UpdatePostAsync(string id, CosmosPostDto item)
 {
     await this._container.UpsertItemAsync <CosmosPostDto>(item, new PartitionKey(id));
 }
 public async Task AddPostAsync(CosmosPostDto item)
 {
     await this._container.CreateItemAsync <CosmosPostDto>(item, new PartitionKey(item.Id));
 }