private void BindCurrentFestivalList(Festival fsv)
 {
     int ItemCount;
     var fsvPics = Festival_DataProvider.GetFestivalPics(out ItemCount, fsv, true, PageSize: fsv.PictureShowCount);
     lstgalleryDataList.DataSource = fsvPics;
     lstgalleryDataList.DataBind();
 }
 public static List<Festival_Pictures> GetFestivalPics(out int PageCount, Festival Curentfsv, bool? Approved = null, int Currentpage = 1, int PageSize = DefaultPageSize)
 {
     using (var ctx = new BMIKidsEntities(ConnectionString))
     {
         var q = from m in ctx.Festival_Pictures
                 where
                 (m.FestivalId == Curentfsv.FestivalId) &&
                 (!Approved.HasValue || m.IsApproved == Approved.Value)
                 select m;
         PageCount = q.Count();
         return q.OrderBy(x => Guid.NewGuid()).Skip((Currentpage - 1) * PageSize).Take(PageSize).ToList();
     }
 }
        public static void SaveFestival(Festival festival)
        {
            using (var ctx = new BMIKidsEntities(ConnectionString))
            {
                try
                {
                    if (festival.ChangeTracker.State == ObjectState.Unchanged)
                        festival.MarkAsModified();

                    ctx.Festivals.ApplyChanges(festival);
                    ctx.SaveChanges();
                }
                catch (Exception ex)
                {
                    LogUtility.WriteEntryEventLog("Festival_DataProvider_DataProvider", ex, EventLogEntryType.Information);
                    if (ex.InnerException != null)
                        throw ex.InnerException;
                    throw;
                }
            }
        }
     private void FixupFestival(Festival previousValue)
     {
         if (IsDeserializing)
         {
             return;
         }
 
         if (previousValue != null && previousValue.Festival_Pictures.Contains(this))
         {
             previousValue.Festival_Pictures.Remove(this);
         }
 
         if (Festival != null)
         {
             if (!Festival.Festival_Pictures.Contains(this))
             {
                 Festival.Festival_Pictures.Add(this);
             }
 
             FestivalId = Festival.FestivalId;
         }
         if (ChangeTracker.ChangeTrackingEnabled)
         {
             if (ChangeTracker.OriginalValues.ContainsKey("Festival")
                 && (ChangeTracker.OriginalValues["Festival"] == Festival))
             {
                 ChangeTracker.OriginalValues.Remove("Festival");
             }
             else
             {
                 ChangeTracker.RecordOriginalValue("Festival", previousValue);
             }
             if (Festival != null && !Festival.ChangeTracker.ChangeTrackingEnabled)
             {
                 Festival.StartTracking();
             }
         }
     }