Exemplo n.º 1
0
 public FoodItem SaveFood(FoodItem item)
 {
     if (item.ID == 0)
     {
         ctx.Food.Add(item);
     }
     else
     {
         ctx.Food.Attach(item);
         ctx.Entry(item).State = EntityState.Modified;
     }
     ctx.SaveChanges();
     return(item);
 }
Exemplo n.º 2
0
        public FoodItem SaveFood(FoodItem item)
        {
            verfiyScope();
            if (item.ID == 0)
            {
                ctx.Food.Add(item);
            }
            else
            {
                ctx.Food.Attach(item);
                ctx.Entry(item).State = EntityState.Modified;
            }

            ctx.SaveChanges();

            if (cfg.FeatureManagement.Reactive)
            {
                publisher.PublishEvent(item, FoodEventType.Update);
            }

            return(item);
        }