Пример #1
0
        public bool UpdateOrganizer(Organizer instance)
        {
            try
            {
                Organizer organizer = Db.Organisers.Find(instance.OrganizerId);
                Type type = instance.GetType();

                foreach(var info in type.GetProperties())
                {
                    if(info.CanWrite)
                    {
                        var value = info.GetValue(instance);
                        if(value != null)
                        {
                            info.SetValue(organizer, value, null);
                        }
                    }
                }
                Db.SaveChanges();
                return true;
            }
            catch
            {
                return false;
            }
        }
Пример #2
0
 public bool CreateOrganizer(Organizer instance)
 {
     try
     {
         if (instance.OrganizerId == 0)
         {
             Db.Organisers.Add(instance);
             Db.SaveChanges();
             return true;
         }
         return false;
     }
     catch
     {
         return false;
     }
 }