public async Task <ToDoEntity> UpdateToDoObject(UpdateToDoObjectRequest request) { var updatedEntity = new ToDoEntity(); var connectionString = _configuration.GetConnectionString("MongoConnection"); var table = TableNames.todoobject.ToString(); var userId = request.UserId; var title = request.Title; var description = request.Description; var priority = request.Priority; var newTitle = request.NewTitle; try { await _dBInterface.Update <ToDoEntity>(userId, title, description, priority, newTitle); // Get the newly updated ToDoObject if (!string.IsNullOrEmpty(newTitle)) { updatedEntity = await _dBInterface.Read(userId, newTitle); } else { updatedEntity = await _dBInterface.Read(userId, title); } _logger.LogInformation("Successfully updated ToDoObject"); } catch (Exception ex) { _logger.LogError("Could not find the given ToDoObject", ex); } return(updatedEntity); }
public async Task <UpdateToDoObjectResponse> Update(UpdateToDoObjectRequest request) { var updatedToDoEntity = await _updateToDoObjectService.UpdateToDoObject(request); return(_mapper.Map <UpdateToDoObjectResponse>(updatedToDoEntity)); }