| 12345678910111213141516171819202122232425262728293031323334 |
- using System.ComponentModel.DataAnnotations;
- using System.ComponentModel.DataAnnotations.Schema;
- namespace Recepie.Models
- {
- public class Recipe
- {
- [Key]
- public int Id { get; set; }
- [Required]
- [StringLength(200)]
- public string Title { get; set; } = string.Empty;
- [StringLength(1000)]
- public string? Description { get; set; }
- [StringLength(50)]
- public string? Difficulty { get; set; }
- // Properties that exist in your database - made nullable to handle NULL values
- public string? Url { get; set; }
- public string? Time { get; set; }
- // Navigation properties for ingredients, steps, and images
- public virtual ICollection<RecipeIngredientLink> RecipeIngredients { get; set; } = new List<RecipeIngredientLink>();
- public virtual ICollection<RecipeStep> RecipeSteps { get; set; } = new List<RecipeStep>();
- // public virtual RecipeImage? RecipeImage { get; set; } // Temporarily disabled for main page performance
- // Computed property to get ingredient names
- [NotMapped]
- public List<string> IngredientNames => RecipeIngredients?.Select(ri => ri.Ingredient?.Name ?? "").Where(name => !string.IsNullOrEmpty(name)).ToList() ?? new List<string>();
- }
- }
|