예제 #1
0
 public override bool Equals(System.Object otherCake)
 {
     if (!(otherCake is Cupcake))
     {
         return(false);
     }
     else
     {
         Cupcake newCupcake          = (Cupcake)otherCake;
         bool    IdEquality          = Id.Equals(newCupcake.Id);
         bool    NameEquality        = Name.Equals(newCupcake.Name);
         bool    DescriptionEquality = Description.Equals(newCupcake.Description);
         bool    PriceEquality       = Price.Equals(newCupcake.Price);
         bool    CakeEquality        = Cake.Equals(newCupcake.Cake);
         bool    FrostingEquality    = Frosting.Equals(newCupcake.Frosting);
         bool    ToppingEquality     = Topping.Equals(newCupcake.Topping);
         bool    InventoryEquality   = Inventory.Equals(newCupcake.Inventory);
         bool    ImgUrlEquality      = ImgUrl.Equals(newCupcake.ImgUrl);
         return(IdEquality && NameEquality && DescriptionEquality && PriceEquality && CakeEquality && FrostingEquality && ToppingEquality && InventoryEquality && ImgUrlEquality);
     }
 }
 public void Remove(Cupcake cupcake)
 {
     db.Cupcakes.Remove(cupcake);
     db.SaveChanges();
 }
 public Cupcake Edit(Cupcake cupcake)
 {
     db.Entry(cupcake).State = EntityState.Modified;
     db.SaveChanges();
     return(cupcake);
 }
 public Cupcake Save(Cupcake cupcake)
 {
     db.Cupcakes.Add(cupcake);
     db.SaveChanges();
     return(cupcake);
 }