Guest User

Untitled

a guest
May 21st, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. public List<Recipe> GetRecipes(Cook cook)
  2. {
  3. List<Recipe> L_Recipes = new List<Recipe>();
  4. Cook Cook = dbc.DbCook.SingleOrDefault(c => c.Nickname == cook.Nickname);
  5. L_Recipes = Cook.ListRecipes;
  6. return L_Recipes;
  7. }
  8.  
  9. public class Recipe
  10. {
  11. //Attributes
  12. public int Id { get; set; }
  13. public string Name { get; set; }
  14. public string Type { get; set; }
  15. public float CostPrice { get; set; }
  16. public float SellingPrice { get; set; }
  17. public DateTime Date { get; set; }
  18. public List<Ingredient> ListIngredients { get; set; }
  19. public List<Comment> ListComments { get; set; }
  20. public Schedule Schedules { get; set; }
  21. //Builder
  22. public Recipe(string name, string type)
  23. {
  24. Name = name;
  25. Type = type;
  26. Date = DateTime.Now;
  27. ListIngredients = new List<Ingredient>();
  28. Schedules = new Schedule();
  29. }
  30. public Recipe(string name,string type,float costPrice,float SellingPrice,DateTime Date,List<Ingredient> ListIngredients,List<Comment> ListComments,Schedule Schedules)
  31. {
  32. this.Name = name;
  33. this.Type = type;
  34. this.CostPrice = costPrice;
  35. this.SellingPrice = SellingPrice;
  36. this.Date = Date;
  37. this.ListIngredients = ListIngredients;
  38. this.ListComments = ListComments;
  39. this.Schedules = Schedules;
  40. }
  41. public Recipe() { ListIngredients = new List<Ingredient>(); }
  42. //Methods
  43. public void AddIngredient(Ingredient i)
  44. {
  45. ListIngredients.Add(i);
  46. }
  47. public float CalculCostPrice()
  48. {
  49. float cost = 0;
  50. foreach (Ingredient ing in ListIngredients)
  51. {
  52. cost += ing.CalculCostIngredient();
  53. }
  54. return cost;
  55. }
  56. public float CalculSellingPrice()
  57. {
  58. return (float)(CalculCostPrice()*1.05);
  59. }
  60. public override string ToString()
  61. {
  62. string SP = string.Format("{0:00.00}", SellingPrice);
  63. return $"{Name} for {SP} euros added the {Date.ToString()}";
  64. }
  65. }
  66.  
  67. public List<Recipe> GetRecipes(Cook cook)
  68. {
  69. List<Recipe> L_Recipes = new List<Recipe>();
  70. Cook Cook = dbc.DbCook.Include(c => c.ListRecipes).singleOrDefault(c => c.Nickname == cook.Nickname);
  71. L_Recipes = Cook.ListRecipes;
  72. return L_Recipes;
  73. }
Add Comment
Please, Sign In to add comment