52 lines
1.3 KiB
C#
52 lines
1.3 KiB
C#
using SushiBarContracts.BindingModels;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
using System.Xml.Linq;
|
|
|
|
namespace SushiBarDatabaseImplement.Models
|
|
{
|
|
public class Ingredient
|
|
{
|
|
[Key]
|
|
public int Id { get; set; }
|
|
|
|
[Required]
|
|
public string IngredientName { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public string Unit { get; set; } = string.Empty;
|
|
|
|
[Required]
|
|
public double Cost { get; set; }
|
|
|
|
[ForeignKey("IngredientId")]
|
|
public virtual List<DishIngredient> DishIngredients { get; set; } = new();
|
|
|
|
public static Ingredient? Create(IngredientBindingModel Model)
|
|
{
|
|
return new Ingredient()
|
|
{
|
|
IngredientName = Model.IngredientName,
|
|
name = model.name,
|
|
facultyid = model.facultyid,
|
|
};
|
|
}
|
|
public void Update(CourseBindingModel model)
|
|
{
|
|
if (model == null)
|
|
{
|
|
return;
|
|
}
|
|
name = model.name;
|
|
facultyid = model.facultyid;
|
|
}
|
|
public CourseViewModel ViewModel => new()
|
|
{
|
|
course_id = course_id,
|
|
name = name,
|
|
facultyid = facultyid,
|
|
FacultyName = Faculty.name,
|
|
};
|
|
}
|
|
}
|