Example #1
0
 public Gallery_Collection GetDetails(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString)){
         context.CommandTimeout = Settings.CommandTimeout;
         Gallery_Collection collection = context.Gallery_Collections.Where(p => p.CollectionId == Idx).SingleOrDefault();
         return(collection);
     }
 }
Example #2
0
 public void Delete(int Idx)
 {
     using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
     {
         context.CommandTimeout         = Settings.CommandTimeout;
         context.DeferredLoadingEnabled = false;
         Gallery_Collection collection_obj = context.Gallery_Collections.Single(p => p.CollectionId == Idx);
         context.Gallery_Collections.DeleteOnSubmit(collection_obj);
         context.SubmitChanges();
     }
 }
Example #3
0
        public bool InsertData(int TopicId, string Title, string IconFile, string Description, string Tags, string Url,
                               string UserLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                System.Nullable <Int32> ListOrder  = (int?)context.Gallery_Collections.Max(x => (int?)x.CollectionId) ?? 0;
                Gallery_Collection      collection = new Gallery_Collection();
                collection.TopicId           = TopicId;
                collection.Title             = Title;
                collection.IconFile          = IconFile;
                collection.Description       = Description;
                collection.ListOrder         = ListOrder + 1;
                collection.UserLog           = Guid.Parse(UserLog);
                collection.UserLastUpdate    = Guid.Parse(UserLog);
                collection.CreatedOnDate     = System.DateTime.Now;
                collection.LastModifieddDate = System.DateTime.Now;
                collection.Status            = Convert.ToChar(Status);
                collection.Tags         = Tags;
                collection.Url          = Url;
                collection.IPLog        = IP;
                collection.IPLastUpdate = IP;


                context.Gallery_Collections.InsertOnSubmit(collection);
                context.SubmitChanges();
                int newCollectionId = collection.CollectionId;
                if (newCollectionId > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #4
0
        public bool UpdateData(int Idx, int TopicId, string Title, string IconFile, string Description, int ListOrder, string Tags, string Url,
                               string UserLog, string UserLastUpdate, DateTime CreatedOnDate, string IPLog, string Status)
        {
            using (GalleryDataContext context = new GalleryDataContext(Settings.ConnectionString))
            {
                context.Connection.Open();
                Gallery_Collection collection_obj = new Gallery_Collection();
                collection_obj.CollectionId      = Idx;
                collection_obj.TopicId           = TopicId;
                collection_obj.Title             = Title;
                collection_obj.IconFile          = IconFile;
                collection_obj.Description       = Description;
                collection_obj.ListOrder         = ListOrder;
                collection_obj.UserLog           = Guid.Parse(UserLog);
                collection_obj.UserLastUpdate    = Guid.Parse(UserLastUpdate);
                collection_obj.CreatedOnDate     = CreatedOnDate;
                collection_obj.LastModifieddDate = DateTime.Now;
                collection_obj.Status            = Convert.ToChar(Status);
                collection_obj.Tags         = Tags;
                collection_obj.Url          = Url;
                collection_obj.IPLog        = IPLog;
                collection_obj.IPLastUpdate = IP;

                ChangeSet     changeSet   = null;
                int           changeCount = 0;
                DbTransaction trans       = context.Connection.BeginTransaction();
                try
                {
                    context.Transaction = trans;
                    context.Gallery_Collections.Attach(collection_obj);
                    context.Refresh(RefreshMode.KeepCurrentValues, collection_obj);
                    changeSet   = context.GetChangeSet();
                    changeCount = changeSet.Updates.Count;
                    context.SubmitChanges();

                    trans.Commit();
                }
                catch (Exception ex)
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    throw ex;
                }
                finally
                {
                    if (context.Connection != null && context.Connection.State == System.Data.ConnectionState.Open)
                    {
                        context.Connection.Close();
                    }
                }

                if (changeCount > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #5
0
 partial void DeleteGallery_Collection(Gallery_Collection instance);
Example #6
0
 partial void UpdateGallery_Collection(Gallery_Collection instance);
Example #7
0
 partial void InsertGallery_Collection(Gallery_Collection instance);