public void Setup() { _client = new RestClient { BaseUrl = new Uri(Constants.API_BASE_URL) }; _client.AddDefaultHeader(Constants.G_TOKEN_NAME, Constants.G_TOKEN_VALUE); _client.Authenticator = new HttpBasicAuthenticator(Constants.AUTHORIZATION_NAME, Constants.AUTHORIZATION_PASSWORD); _gen = new GeneralMethods(); _post = new PostMethods(_client); _get = new GetMethods(_client); _del = new DeleteMethods(_client); }
public Result DeleteMethods(DeleteMethods deleteMethods) { //Will fail if all provided methods do not exist List <long> idsToDelete = deleteMethods.Ids; int numberOfRemovedItems = methodsMemoryDatabase.RemoveAll(m => idsToDelete.Contains(m.Id)); if (numberOfRemovedItems == 0) { return(Result.Fail("All methods you are trying to delete do not exist")); } return(Result.Ok()); }
public IActionResult DeleteMethods([FromBody] List <long> ids) { long loggedInUserId = GetLoggedInUserIdMockUp(); if (loggedInUserId == -1) { return(Unauthorized()); } Console.Write(ids); DeleteMethods deleteMethods = new DeleteMethods(ids, loggedInUserId); _kafkaProducer.Produce(deleteMethods, METHODS_TOPIC); return(Ok("Currently processing your request...")); }
private void HandleDeleteMethods(DeleteMethods deleteMethods) { Result deletionResult = _repository.DeleteMethods(deleteMethods); if (deletionResult.IsFailure) { MethodsDeletionFailed failedCreateMethodsDeletion = new MethodsDeletionFailed( deletionResult.Error, deleteMethods.LoggedInUserId, deleteMethods.SagaId ); _kafkaProducer.Produce(failedCreateMethodsDeletion, METHODS_TOPIC); return; } List <long> deletedIds = deleteMethods.Ids.Select(id => id).ToList(); MethodsDeleted deletedMethod = new MethodsDeleted(deletedIds, deleteMethods.LoggedInUserId, deleteMethods.SagaId); _kafkaProducer.Produce(deletedMethod, METHODS_TOPIC); }
// /// <summary> /// DELETE TABLE table |tableName| /// DELETE COLUMN |tableName| |colName| /// DELETE ELEMENT |tableName| |ID(int)| /// DELETE ELEMENT |tableName| WHERE (colName=value,...) /// DELETE ELEMENT |tableName| WHERE |colName| BETWEEN (1,2) /// </summary> /// <param name="query"></param> private static void Delete(string query) { string _command = query.Substring(6); DeleteMethods.Execute(_command); }