Beispiel #1
0
        public static void Update(hall new_hall, long hall_id)
        {
            var hall = context.halls.Find(hall_id);

            if (hall != null && hall.status == false)
            {
                hall.name = new_hall.name;
                foreach (price_list pl in hall.price_lists.ToList())
                {
                    if (!new_hall.price_lists.Any(p => p.id == pl.id))
                    {
                        price_list.Delete(pl.id);
                    }
                }
                foreach (price_list pl in new_hall.price_lists)
                {
                    var new_price_list = hall.price_lists.FirstOrDefault(p => p.id == pl.id);
                    if (new_price_list != null)
                    {
                        price_list.Update(new_price_list, pl.id);
                    }
                    else if (new_price_list == null)
                    {
                        pl.hall = hall;
                        price_list.Insert(pl);
                    }
                }
                context.SaveChanges();
            }
        }
Beispiel #2
0
 public static long Insert(hall hall)
 {
     context.halls.Add(hall);
     context.SaveChanges();
     return(hall.id);
 }