public async Task <CustomResponse> RemoveAllInstructionsFromRecipe(int recipeId) { DbConnection db = new DbConnection(); try { var query = @$ "DELETE FROM instruction WHERE recipe = {recipeId};"; await db.ExecuteQuery(query); return(new CustomResponse(1, "")); } catch { return(CustomResponse.ErrorMessage()); } finally { db.CloseConnection(); } }
public async Task <CustomResponse> AddTag(Tag tag) { CustomResponse response = await CheckNewTagValid(tag); if (response.Value == 0) { // component is invalid. return respones message return(response); } DbConnection db = new DbConnection(); try { var query = $"INSERT INTO tag (name) VALUES ('{tag.Name.Trim()}');"; await db.ExecuteQuery(query); var storedComponent = await GetTagByName(tag.Name); return(new CustomResponse((int)storedComponent.Id, $"Tag {tag.Name} erfolgreich hinzugefügt")); } catch { return(CustomResponse.ErrorMessage()); } finally { db.CloseConnection(); } }