/// <summary>
        /// Adds the mock API.
        /// </summary>
        /// <param name="mockApi">The mock API.</param>
        /// <returns>Mock API definition</returns>
        public async Task <MockApiModel> AddMockApiAsync(MockApiModel mockApi, string collectionName)
        {
            var collectionEntity = await RetrieveCollectionEntity(collectionName);

            if (collectionEntity == null)
            {
                throw new CollectionNotFoundException();
            }

            var table = await this.GetTableReferenceAsync();

            var mockApiEntity = new MockApiEntity(mockApi.Name, collectionEntity.CollectionName)
            {
                RouteTemplate = mockApi.RouteTemplate,
                Verb          = mockApi.Verb.ToString(),
                Body          = mockApi.Body,
                Language      = mockApi.Language.ToString()
            };

            try
            {
                var insertOperation = TableOperation.Insert(mockApiEntity);
                await table.ExecuteAsync(insertOperation);
            }
            catch (StorageException ex)
            {
                if (ex.RequestInformation.HttpStatusCode == 409)
                {
                    throw new ResourceConflictException();
                }
                throw;
            }

            return(mockApi);
        }
        /// <summary>
        /// Adds the mock API.
        /// </summary>
        /// <param name="mockApi">The mock API.</param>
        /// <returns>Mock API definition</returns>
        public Task <MockApiModel> AddMockApiAsync(MockApiModel mockApi, string collectionName)
        {
            var collectionEntity = table.SingleOrDefault(x => x.RowKey == collectionName.ToLower() && x.PartitionKey == collectionName.ToLower());

            if (collectionEntity == null)
            {
                throw new ResourceNotFoundException();
            }

            var mockApiEntity = new MockApiEntity(mockApi.Name, collectionEntity.Name)
            {
                RouteTemplate = mockApi.RouteTemplate,
                Verb          = mockApi.Verb.ToString(),
                Body          = mockApi.Body,
                Language      = mockApi.Language.ToString()
            };

            if (table.Any(x => x.RowKey == mockApiEntity.RowKey))
            {
                throw new ResourceConflictException();
            }

            table.Add(mockApiEntity);

            return(Task.FromResult(mockApi));
        }
        /// <summary>
        /// Creates the collection.
        /// </summary>
        /// <param name="collectionName">Name of the collection.</param>
        /// <returns>task object</returns>
        public Task CreateCollectionAsync(string collectionName)
        {
            var collectionEntity = new MockApiEntity(collectionName, collectionName);

            if (table.Any(x => x.PartitionKey == collectionEntity.PartitionKey))
            {
                throw new ResourceConflictException();
            }
            table.Add(collectionEntity);

            return(Task.FromResult(0));
        }
        /// <summary>
        /// Creates the collection.
        /// </summary>
        /// <param name="collectionName">Name of the collection.</param>
        /// <returns>task object</returns>
        public async Task CreateCollectionAsync(string collectionName)
        {
            try
            {
                var table = await this.GetTableReferenceAsync();

                var collectionEntity = new MockApiEntity(collectionName, collectionName);
                var insertOperation  = TableOperation.Insert(collectionEntity);
                await table.ExecuteAsync(insertOperation);
            }
            catch (StorageException ex)
            {
                if (ex.RequestInformation.HttpStatusCode == 409)
                {
                    throw new ResourceConflictException();
                }
                throw;
            }
        }