Example #1
0
        public async Task <IActionResult> PutAsync(string userId, [FromBody] Board board)
        {
            // Validate input and return 400 Bad Request if invalid
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            // Create the valid data entity
            var entity = new BoardEntity
            {
                PartitionKey = userId,
                RowKey       = board.Id,
                Name         = board.Name,
                OwnerId      = board.OwnerId
            };

            // Update the data
            var updatedEntity = await _boardRepository.InsertOrMergeAsync(entity);

            // Create the return contract
            var updatedBoard = new Board
            {
                Id      = updatedEntity.RowKey,
                Name    = updatedEntity.Name,
                OwnerId = updatedEntity.OwnerId
            };

            // Return 200 OK
            return(Ok(updatedBoard));
        }
Example #2
0
        public async Task <Ninja> UpdateAsync(Ninja ninja)
        {
            var entityToUpdate = _ninjaMappingService.Map(ninja);
            var updatedEntity  = await _ninjaEntityTableStorageRepository.InsertOrMergeAsync(entityToUpdate);

            var updatedNinja = _ninjaMappingService.Map(updatedEntity);

            return(updatedNinja);
        }
Example #3
0
        public async Task <Card> UpdateAsync(Card card)
        {
            var entityToUpdate = _mapper.Map <CardEntity>(card);
            var updatedEntity  = await _cardRepository.InsertOrMergeAsync(entityToUpdate);

            var updatedCard = _mapper.Map <Card>(updatedEntity);

            return(updatedCard);
        }
        public async Task <User> UpdateAsync(User user)
        {
            // Convert the user to its entity equivalent
            var entity = _mapper.Map <UserEntity>(user);

            // Update the user
            var updatedEntity = await _userRepository.InsertOrMergeAsync(entity);

            // Queue the "user updated" message
            await _queuesService.UserUpdatedQueue.AddMessageAsync(new TableMessage
            {
                PartitionKey = updatedEntity.PartitionKey,
                RowKey       = updatedEntity.RowKey
            });

            // Return the updated user
            var updatedUser = _mapper.Map <User>(updatedEntity);

            return(updatedUser);
        }