public RecipeDto GetRecipe(int id) { IDataAccessObject dao = daoFactory.GetDao(); return(new RecipeDto() { adaptee = dao.GetRecipe(id) }); }
public RecipeDto Get(int id) { var result = (RecipeDto)cache.GetValue(id.ToString()); if (result == null) { IDataAccessObject dao = daoFactory.GetDao(); result = dao.GetRecipe(id); if (result != null) { cache.Add(id.ToString(), result, DateTimeOffset.UtcNow.AddMinutes(15)); } } return(result); }
public void GetRecipeTest() { // Arrange IDataAccessObjectFactory factory = DatabaseFactory.GetInstance(); IDataAccessObject database = factory.GetDao(); var list = database.GetRecipeList(); int id = list[0].IdRecipe; // Act var r = database.GetRecipe(id); if (r == null) { Debug.WriteLine("Check connection: " + factory.GetConnectionString()); Assert.Fail(); } }