public IActionResult ModifyOverview() { var recipes = RecipesService.GetAll(); var modifyOverviewModels = recipes .Select(x => ModelConverter.ConverToModifyOverviewModel(x)) .ToList(); return(View(modifyOverviewModels)); }
public ActionResult <Recipe> Get() { try { return(Ok(_rs.GetAll())); } catch (Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <IEnumerable <Recipe> > GetAll() { try { return(Ok(_service.GetAll())); } catch (System.Exception e) { return(BadRequest(e.Message)); } }
public ActionResult <IEnumerable <Recipe> > GetAll() { try { IEnumerable <Recipe> recipes = _service.GetAll(); return(Ok(recipes)); } catch (Exception e) { return(BadRequest(e.Message)); } }
public async Task GetAllShouldReturnCollection() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options; AutoMapperConfig.RegisterMappings(Assembly.Load("CookingBook.Web.ViewModels")); var dbContext = new ApplicationDbContext(options); dbContext.Recipes.Add(new Recipe()); dbContext.Recipes.Add(new Recipe()); await dbContext.SaveChangesAsync(); var recipeRepo = new EfDeletableEntityRepository <Recipe>(dbContext); var nutritionRepo = new EfDeletableEntityRepository <NutritionValue>(dbContext); var productRepo = new EfDeletableEntityRepository <Product>(dbContext); var userRepo = new EfDeletableEntityRepository <ApplicationUser>(dbContext); var service = new RecipesService(recipeRepo, nutritionRepo, productRepo, userRepo); Assert.Equal(2, service.GetAll <RecipeInCategoryViewModel>().Count()); }
#pragma warning disable 1998 public async override global::System.Threading.Tasks.Task ExecuteAsync() { BeginContext(7, 2, true); WriteLiteral("\r\n"); EndContext(); #line 3 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" var recipes = RecipesService.GetAll(); #line default #line hidden BeginContext(61, 2, true); WriteLiteral("\r\n"); EndContext(); DefineSection("Title", async() => { BeginContext(78, 61, true); WriteLiteral("\r\n <h2 class=\"modal-title\">My Favorite Recipies</h2>\r\n "); EndContext(); BeginContext(139, 84, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "13493ffdc2954dde90cb0b88a8e8923b", async() => { BeginContext(209, 10, true); WriteLiteral("Add Recipe"); EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Page = (string)__tagHelperAttribute_0.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_0); __tagHelperExecutionContext.AddHtmlAttribute(__tagHelperAttribute_1); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(223, 2, true); WriteLiteral("\r\n"); EndContext(); } ); BeginContext(228, 29, true); WriteLiteral("\r\n<div class=\"row recipes\">\r\n"); EndContext(); #line 14 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" foreach (var recipe in recipes) { #line default #line hidden BeginContext(406, 81, true); WriteLiteral(" <div class=\"recipe col-md-4\">\r\n <img class=\"img img-thumbnail\""); EndContext(); BeginWriteAttribute("src", " src=\"", 487, "\"", 520, 1); #line 18 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" WriteAttributeValue("", 493, recipe.GetInlineImageSrc(), 493, 27, false); #line default #line hidden EndWriteAttribute(); BeginContext(521, 21, true); WriteLiteral(" />\r\n <h3>"); EndContext(); BeginContext(542, 64, false); __tagHelperExecutionContext = __tagHelperScopeManager.Begin("a", global::Microsoft.AspNetCore.Razor.TagHelpers.TagMode.StartTagAndEndTag, "2460a9f8596b448394ac061ffade6278", async() => { BeginContext(591, 11, false); #line 19 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" Write(recipe.Name); #line default #line hidden EndContext(); } ); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper = CreateTagHelper <global::Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper>(); __tagHelperExecutionContext.Add(__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.Page = (string)__tagHelperAttribute_2.Value; __tagHelperExecutionContext.AddTagHelperAttribute(__tagHelperAttribute_2); if (__Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues == null) { throw new InvalidOperationException(InvalidTagHelperIndexerAssignment("asp-route-id", "Microsoft.AspNetCore.Mvc.TagHelpers.AnchorTagHelper", "RouteValues")); } BeginWriteTagHelperAttribute(); #line 19 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" WriteLiteral(recipe.Id); #line default #line hidden __tagHelperStringValueBuffer = EndWriteTagHelperAttribute(); __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"] = __tagHelperStringValueBuffer; __tagHelperExecutionContext.AddTagHelperAttribute("asp-route-id", __Microsoft_AspNetCore_Mvc_TagHelpers_AnchorTagHelper.RouteValues["id"], global::Microsoft.AspNetCore.Razor.TagHelpers.HtmlAttributeValueStyle.DoubleQuotes); await __tagHelperRunner.RunAsync(__tagHelperExecutionContext); if (!__tagHelperExecutionContext.Output.IsContentModified) { await __tagHelperExecutionContext.SetOutputContentAsync(); } Write(__tagHelperExecutionContext.Output); __tagHelperExecutionContext = __tagHelperScopeManager.End(); EndContext(); BeginContext(606, 7, true); WriteLiteral("</h3>\r\n"); EndContext(); BeginContext(674, 15, true); WriteLiteral(" <p>"); EndContext(); BeginContext(690, 18, false); #line 21 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" Write(recipe.Description); #line default #line hidden EndContext(); BeginContext(708, 22, true); WriteLiteral("</p>\r\n </div>\r\n"); EndContext(); #line 23 "C:\Users\Maxwell Wright\source\repos\TopsyTurvyCakes\TopsyTurvyCakes\Pages\Index.cshtml" } #line default #line hidden BeginContext(739, 6, true); WriteLiteral("</div>"); EndContext(); }