Exemplo n.º 1
0
 public bool update(DrinkAndDessert drinkAndDessert, int id)
 {
     try
     {
         drinkAndDessert.updated_at = DateTime.Now;
         (from drink in db.DrinkAndDesserts
          where drink.id_drink == id
          select drink)
         .ToList()
         .ForEach((p) =>
         {
             p.id_type     = drinkAndDessert.id_type;
             p.name        = drinkAndDessert.name;
             p.price       = drinkAndDessert.price;
             p.updated_at  = drinkAndDessert.updated_at;
             p.image       = drinkAndDessert.image;
             p.description = drinkAndDessert.description;
         });
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }
Exemplo n.º 2
0
 public bool create(DrinkAndDessert drinkAndDessert)
 {
     try
     {
         drinkAndDessert.created_at = DateTime.Now;
         drinkAndDessert.updated_at = DateTime.Now;
         db.DrinkAndDesserts.Add(drinkAndDessert);
         db.SaveChanges();
         return(true);
     }
     catch (Exception e)
     {
         return(false);
     }
 }