Fixed errors SA1516
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
namespace Francesco.Recipes.World.Data
|
||||
{
|
||||
namespace Francesco.Recipes.World.Data;
|
||||
|
||||
using Francesco.Recipes.World.Models.BackendModels;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Category;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Favorit;
|
||||
@@ -21,15 +21,25 @@
|
||||
}
|
||||
|
||||
public DbSet<Category> Categories => Set<Category>();
|
||||
|
||||
public DbSet<Ingredient> Ingredients => Set<Ingredient>();
|
||||
|
||||
public DbSet<Instruction> Instructions => Set<Instruction>();
|
||||
|
||||
public DbSet<Recipe> Recipes => Set<Recipe>();
|
||||
|
||||
public DbSet<RecipeIngredient> RecipeIngredients => Set<RecipeIngredient>();
|
||||
|
||||
public DbSet<Unit> Units => Set<Unit>();
|
||||
|
||||
public DbSet<Favorit> Favorits => Set<Favorit>();
|
||||
|
||||
public DbSet<IngredientsShoppingList> IngredientsShoppingLists => Set<IngredientsShoppingList>();
|
||||
|
||||
public DbSet<ShoppingList> ShoppingLists => Set<ShoppingList>();
|
||||
|
||||
public DbSet<MediaFile> MediaFiles => Set<MediaFile>();
|
||||
|
||||
public override Task<int> SaveChangesAsync(CancellationToken cancellationToken = default)
|
||||
{
|
||||
foreach (var entry in ChangeTracker.Entries())
|
||||
@@ -104,4 +114,3 @@
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
// <auto-generated />
|
||||
using System;
|
||||
|
||||
using Francesco.Recipes.World.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
|
||||
|
||||
#nullable disable
|
||||
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
namespace Francesco.Recipes.World.Models.BackendModels.Category
|
||||
{
|
||||
using Francesco.Recipes.World.Models.BackendModels.Recipe;
|
||||
|
||||
public class Category
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public virtual ICollection<Recipe> Recipes { get; set; } = new List<Recipe>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@
|
||||
public class Favorit
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public virtual ICollection<Recipe> Recipe { get; set; } = new List<Recipe>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,11 @@
|
||||
public class Ingredient
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public virtual ICollection<RecipeIngredient> RecipeIngredients { get; set; } = new List<RecipeIngredient>();
|
||||
|
||||
public virtual ICollection<IngredientsShoppingList> IngredientShoppingLists { get; set; } = new List<IngredientsShoppingList>();
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -6,7 +6,9 @@
|
||||
public class IngredientsShoppingList
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public ShoppingList Shoppinglist { get; set; } = new ();
|
||||
|
||||
public Ingredient Ingredient { get; set; } = new ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
{
|
||||
using Francesco.Recipes.World.Models.BackendModels.MediaFile;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Recipe;
|
||||
|
||||
public class Instruction
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
public int Number { get; set; }
|
||||
|
||||
public virtual Recipe Recipe { get; set; } = new ();
|
||||
|
||||
public virtual ICollection<MediaFile> MediaFiles { get; set; } = new List<MediaFile>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
{
|
||||
using Francesco.Recipes.World.Models.BackendModels.Instruction;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Recipe;
|
||||
|
||||
public class MediaFile
|
||||
{
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
@@ -11,7 +12,9 @@
|
||||
public string? MimeType { get; set; }
|
||||
|
||||
public byte[]? Data { get; set; }
|
||||
|
||||
public virtual Recipe? Recipe { get; set; } = new ();
|
||||
|
||||
public virtual Instruction Instruction { get; set; } = new ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,9 +3,13 @@
|
||||
public enum Difficulty
|
||||
{
|
||||
VeryEasy = 1,
|
||||
|
||||
Easy = 2,
|
||||
|
||||
Medium = 3,
|
||||
|
||||
Hard = 4,
|
||||
|
||||
Expert = 5,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,17 +8,30 @@ using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient;
|
||||
public class Recipe : ITimeStampedEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string? Description { get; set; }
|
||||
|
||||
public Difficulty Difficulty { get; set; }
|
||||
|
||||
public int Servings { get; set; }
|
||||
|
||||
public TimeSpan PreparationTime { get; set; }
|
||||
|
||||
public TimeSpan CookingTime { get; set; }
|
||||
|
||||
public bool IsFavorite { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public DateTime? ModifiedAt { get; set; }
|
||||
|
||||
public virtual ICollection<RecipeIngredient> RecipeIngredients { get; set; } = new List<RecipeIngredient>();
|
||||
|
||||
public virtual ICollection<Instruction> Instructions { get; set; } = new List<Instruction>();
|
||||
|
||||
public virtual ICollection<MediaFile> MediaFiles { get; set; } = new List<MediaFile>();
|
||||
|
||||
public virtual Favorit Favorit { get; set; } = new ();
|
||||
}
|
||||
|
||||
@@ -3,12 +3,17 @@
|
||||
using Francesco.Recipes.World.Models.BackendModels.Ingredient;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Recipe;
|
||||
using Francesco.Recipes.World.Models.BackendModels.Unit;
|
||||
|
||||
public class RecipeIngredient
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public virtual Recipe Recipe { get; set; } = new ();
|
||||
|
||||
public virtual Ingredient Ingredient { get; set; } = new ();
|
||||
|
||||
public virtual Unit Unit { get; set; } = new ();
|
||||
|
||||
public int Quantity { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
public class ShoppingList : ITimeStampedEntity
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; }
|
||||
|
||||
public DateTime? ModifiedAt { get; set; }
|
||||
|
||||
public virtual ICollection<IngredientsShoppingList> IngredientsShoppingLists { get; set; } = new List<IngredientsShoppingList>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
namespace Francesco.Recipes.World.Models.BackendModels.Unit;
|
||||
|
||||
namespace Francesco.Recipes.World.Models.BackendModels.Unit
|
||||
{
|
||||
using Francesco.Recipes.World.Models.BackendModels.RecipeIngredient;
|
||||
|
||||
public class Unit
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
|
||||
public virtual ICollection<RecipeIngredient> RecipeIngredient { get; set; } = new List<RecipeIngredient>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,22 @@
|
||||
using Francesco.Recipes.World.Data;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Serilog;
|
||||
|
||||
using Francesco.Recipes.World.Repositories;
|
||||
|
||||
using FrancescoRecipesWorld.Repositories;
|
||||
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
|
||||
var services = builder.Services;
|
||||
|
||||
var configuration = builder.Configuration;
|
||||
|
||||
var connectionString = builder.Configuration.GetConnectionString("FrancescosRecipesWorldDbContextConnection")
|
||||
?? throw new InvalidOperationException("Connection string 'FrancescosRecipesWorldDbContextConnection' not found.");
|
||||
|
||||
services.AddDbContext<FrancescosRecipesWorldDbContext>(options =>
|
||||
options.UseSqlServer(connectionString));
|
||||
|
||||
@@ -19,6 +26,14 @@ services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfi
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
builder.Services.AddScoped<IRecipeRepository, RecipeRepository>();
|
||||
|
||||
builder.Services.AddScoped<IIngredientRepository, IngredientRepository>();
|
||||
|
||||
builder.Services.AddScoped<IUnitRepository, UnitRepository>();
|
||||
|
||||
builder.Services.AddScoped<ICategoryRepository, CategoryRepository>();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Configure the HTTP request pipeline.
|
||||
@@ -31,9 +46,11 @@ if (!app.Environment.IsDevelopment())
|
||||
}
|
||||
|
||||
app.UseHttpsRedirection();
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
||||
app.UseRouting();
|
||||
|
||||
app.UseAuthentication();
|
||||
|
||||
app.UseAuthorization();
|
||||
|
||||
Reference in New Issue
Block a user