public static List<Media_Albums> GetActiveListByTypeIdFixedNum(int TypeId, int iTotalItemCount) { using (System.Transactions.TransactionScope transScope = new System.Transactions.TransactionScope()) { List<Media_Albums> lst = new List<Media_Albums>(); using (MediaEntities dbContext = new MediaEntities()) { try { dbContext.CommandTimeout = 216000; var query = from x in dbContext.Media_Albums where x.Status =="1" && x.TypeId ==TypeId orderby x.AlbumId descending select x; int TotalItemCount = 0; if (query.Count() > 0) { if (iTotalItemCount <= query.Count()) TotalItemCount = iTotalItemCount; else TotalItemCount = query.Count(); } lst = query.Take(TotalItemCount).ToList(); transScope.Complete(); }catch(Exception ex){ex.InnerException.Message.ToString();} finally { if (dbContext.Connection.State != System.Data.ConnectionState.Closed) dbContext.Connection.Close(); } return lst; } } }
//INSERT- UPDATE - DELETE public int Insert(string UserId, int TypeId, int ParentId, string Name, string Photo, string Description, string Status) { string Alias = module_obj.createTags(Name); using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; System.Nullable<Int32> ListOrder = (from u in dbContext.Media_Types select u.TypeId).DefaultIfEmpty(0).Max() + 1; Media_Topics topic_obj = new Media_Topics(); topic_obj.TypeId = TypeId; topic_obj.Name = Name; topic_obj.Alias = Alias; topic_obj.ParentId = ParentId; topic_obj.ListOrder = (ListOrder == null ? 1 : ListOrder); topic_obj.Photo = Photo; topic_obj.Description = Description; topic_obj.IPLog = IP; topic_obj.CreatedByUserId = new Guid(UserId); topic_obj.CreatedOnDate = System.DateTime.Now; topic_obj.Status = Status; dbContext.AddToMedia_Topics(topic_obj); int i = dbContext.SaveChanges(); return i; } }
public Media_Topics GetDetailById(int idx) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Topics topic_obj = dbContext.Media_Topics.Where(x => x.TopicId == idx).FirstOrDefault(); return topic_obj; } }
public static List<Media_Composers> LoadAll() { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; _items = (from x in dbContext.Media_Composers select x).ToList(); return _items; } }
public string GetTypePathByTypeId(int idx) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; string TypePath = (from x in dbContext.Media_Types where x.TypeId == idx select x.TypePath).SingleOrDefault(); return TypePath; } }
public Media_Types GetDetails(int idx) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Types type_obj = dbContext.Media_Types.Where(x => x.TypeId == idx).FirstOrDefault(); return type_obj; } }
public List<Media_Topics> GetListByStatus(string Status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; IQueryable<Media_Topics> query = from x in dbContext.Media_Topics select x; if (!string.IsNullOrEmpty(Status)) query = query.Where(x => x.Status == Status); return query.ToList(); } }
public static List<Media_Composers> GetListByStatus(string status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; IQueryable<Media_Composers> query = from x in dbContext.Media_Composers select x; if (string.IsNullOrEmpty(status)) _items = query.ToList(); else _items = query.Where(x => x.Status == status).ToList(); return _items; } }
//================================================================================ public static List<Media_Artists> GetActiveListByFixedNum(int iTotalItemCount) { using (MediaEntities dbContext = new MediaEntities()) { var query = from x in dbContext.Media_Artists where x.Status.Equals("1") orderby x.ArtistId descending select x; int TotalItemCount = 0; if (iTotalItemCount <= query.Count()) TotalItemCount = iTotalItemCount; else TotalItemCount = query.Count(); return query.Take(TotalItemCount).ToList(); } }
public List<Media_Types> GetListByStatus(string status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; IQueryable<Media_Types> query = from x in dbContext.Media_Types select x; List<Media_Types> lst= new List<Media_Types>(); if (string.IsNullOrEmpty(status)) lst = query.ToList(); else lst = query.Where(x => x.Status == status).ToList(); return lst; } }
//================================================================================================= public static List<Media_PlayLists> GetActiveListByTypeIdFixedNum(int TypeId, int iTotalItemCount) { using (MediaEntities dbContext = new MediaEntities()) { var query = from x in dbContext.Media_PlayLists where x.Status=="1" && x.TypeId==TypeId orderby x.PlayListId descending select x; int TotalItemCount = 0; if (query.Count() > 0) { if (iTotalItemCount <= query.Count()) TotalItemCount = iTotalItemCount; else TotalItemCount = query.Count(); } return query.Take(TotalItemCount).ToList(); } }
public static List<Media_Composers> LoadDatedItemsByPage(string status, int startRow, int pageSize, string sortBy, bool sortAscending) { using (MediaEntities dbContext = new MediaEntities()) { //List<Media_Artists> list = (from p in dbContext.Media_Artists select p).Skip(startRow * pageSize).Take(pageSize).ToList(); SortData(sortBy, sortAscending); //copy to an array int count = pageSize; _items = GetListByStatus(status); if ((_items.Count - startRow) < count) count = _items.Count - startRow; Media_Composers[] pagearray = new Media_Composers[count]; _items.CopyTo(startRow, pagearray, 0, count); //then create a list from array List<Media_Composers> page = new List<Media_Composers>(pagearray); return page; } }
//INSERT- UPDATE - DELETE public int Insert(string UserId, string TypeName, string TypeExt, string TypePath, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; System.Nullable<Int32> ListOrder = (from u in dbContext.Media_Types select u.TypeId).DefaultIfEmpty(0).Max() + 1; Media_Types type_obj = new Media_Types(); type_obj.TypeName = TypeName; type_obj.TypeExt = TypeExt; type_obj.TypePath = TypePath; type_obj.Description = Description; type_obj.CreatedByUserId = new Guid(UserId); type_obj.CreatedOnDate = System.DateTime.Now; type_obj.IPLog = IP; type_obj.ListOrder = (ListOrder == null ? 1 : ListOrder); type_obj.Status = Status; dbContext.AddToMedia_Types(type_obj); int i = dbContext.SaveChanges(); return i; } }
//INSERT- UPDATE - DELETE public int Insert(string UserId, string ComposerName, string FrontImage, string MainImage, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { string Alias = StringUtils.GenerateFriendlyString(ComposerName); dbContext.CommandTimeout = Settings.CommandTimeout; System.Nullable<Int32> ListOrder = (from u in dbContext.Media_Composers select u.ListOrder).DefaultIfEmpty(0).Max() + 1; Media_Composers composers_obj = new Media_Composers(); composers_obj.ComposerName = ComposerName; composers_obj.Alias = Alias; composers_obj.FrontImage = FrontImage; composers_obj.MainImage = MainImage; composers_obj.Description = Description; composers_obj.ListOrder = (ListOrder == null ? 1 : ListOrder); composers_obj.IPLog = IP; composers_obj.CreatedOnDate = System.DateTime.Now; composers_obj.CreatedByUserId = new Guid(UserId); composers_obj.Status = Status; dbContext.AddToMedia_Composers(composers_obj); int i = dbContext.SaveChanges(); return i; } }
public int UpdateSortKey(string UserId, int PlayListId, int SortOrder) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_PlayLists playLists_obj = dbContext.Media_PlayLists.Single(x => x.PlayListId == PlayListId); playLists_obj.IPModifiedLog = IP; playLists_obj.LastModifiedOnDate = System.DateTime.Now; playLists_obj.LastModifiedByUserId = new Guid(UserId); playLists_obj.SortOrder = SortOrder; int i = dbContext.SaveChanges(); return i; } }
public int Update(int PlayListId,int TypeId, string UserId, string PlayListName, string FrontImage, string MainImage, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { string Alias = StringUtils.GenerateFriendlyString(PlayListName); dbContext.CommandTimeout = Settings.CommandTimeout; Media_PlayLists entity = dbContext.Media_PlayLists.Single(x => x.PlayListId == PlayListId); entity.TypeId = TypeId; entity.PlayListName = PlayListName; entity.Alias = Alias; entity.FrontImage = FrontImage; entity.MainImage = MainImage; entity.Description = Description; entity.IPModifiedLog = IP; entity.LastModifiedOnDate = System.DateTime.Now; entity.LastModifiedByUserId = new Guid(UserId); entity.Status = Status; int i = dbContext.SaveChanges(); return i; } }
//INSERT- UPDATE - DELETE public int Insert(string UserId, int TypeId, string PlayListName, string FrontImage, string MainImage, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { string Alias = StringUtils.GenerateFriendlyString(PlayListName); dbContext.CommandTimeout = Settings.CommandTimeout; System.Nullable<Int32> SortOrder = (from u in dbContext.Media_PlayLists select u.SortOrder).DefaultIfEmpty(0).Max() + 1; Media_PlayLists entity = new Media_PlayLists(); entity.TypeId = TypeId; entity.PlayListName = PlayListName; entity.Alias = Alias; entity.FrontImage = FrontImage; entity.MainImage = MainImage; entity.Description = Description; entity.SortOrder = (SortOrder == null ? 1 : SortOrder); entity.IPLog = IP; entity.CreatedOnDate = System.DateTime.Now; entity.CreatedByUserId = new Guid(UserId); entity.Status = Status; dbContext.AddToMedia_PlayLists(entity); int i = dbContext.SaveChanges(); return i; } }
public int UpdateSortKey(string UserId, int ArtistId, int ListOrder) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Artists artists_obj = dbContext.Media_Artists.Single(x => x.ArtistId == ArtistId); artists_obj.IPLastUpdate = IP; artists_obj.LastModifiedByUserId = new Guid(UserId); artists_obj.LastModifiedDate = System.DateTime.Now; artists_obj.ListOrder = ListOrder; int i = dbContext.SaveChanges(); return i; } }
public int UpdateStatus(string UserId, int TopicId, string Status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Topics topic_obj = dbContext.Media_Topics.Single(x => x.TopicId == TopicId); topic_obj.TopicId = TopicId; topic_obj.Status = Status; topic_obj.LastModifiedByUserId = new Guid(UserId); topic_obj.LastModifiedDate = System.DateTime.Now; int i = dbContext.SaveChanges(); return i; } }
public int Delete(string UserId, int Idx, string Dir_Path) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; string filename = (from x in dbContext.Media_Topics where x.TopicId == Idx select x.Photo).SingleOrDefault(); if (filename != null && filename != string.Empty) module_obj.deleteFile(filename, Dir_Path); //Media_Topics topic_obj = (from x in dbContext.Media_Topics where x.TopicId == Idx select x).First(); Media_Topics topic_obj = dbContext.Media_Topics.Single(x => x.TopicId == Idx); dbContext.DeleteObject(topic_obj); int i = dbContext.SaveChanges(); return i; } }
public int Update(string UserId, int TypeId, int TopicId, int ParentId, string Name, string Photo, string Description, string Status) { string Alias = module_obj.createTags(Name); using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Topics topic_obj = dbContext.Media_Topics.Single(x => x.TopicId == TopicId); topic_obj.TypeId = TypeId; topic_obj.TopicId = TopicId; topic_obj.Name = Name; topic_obj.Alias = Alias; topic_obj.ParentId = ParentId; topic_obj.Photo = Photo; topic_obj.Description = Description; topic_obj.IPLog = IP; topic_obj.CreatedByUserId = new Guid(UserId); topic_obj.CreatedOnDate = System.DateTime.Now; topic_obj.Status = Status; int i = dbContext.SaveChanges(); return i; } }
public int Delte(int TypeId) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; //Media_Types type_obj = (from x in dbContext.Media_Types where x.TypeId == TypeId select x).First(); Media_Types type_obj = dbContext.Media_Types.Single(x => x.TypeId == TypeId); dbContext.DeleteObject(type_obj); int i = dbContext.SaveChanges(); return i; } }
public int UpdateSortKey(string UserId, int TypeId, int ListOrder) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Types type_obj = dbContext.Media_Types.Single(x => x.TypeId == TypeId); type_obj.TypeId = TypeId; type_obj.ListOrder = ListOrder; type_obj.LastModifiedByUserId = new Guid(UserId); type_obj.ModifiedDate = System.DateTime.Now; int i = dbContext.SaveChanges(); return i; } }
public int Update(int ComposerId, string UserId, string ComposerName, string FrontImage, string MainImage, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { string Alias = StringUtils.GenerateFriendlyString(ComposerName); dbContext.CommandTimeout = Settings.CommandTimeout; Media_Composers composers_obj = dbContext.Media_Composers.Single(x => x.ComposerId == ComposerId); composers_obj.ComposerName = ComposerName; composers_obj.Alias = Alias; composers_obj.FrontImage = FrontImage; composers_obj.MainImage = MainImage; composers_obj.Description = Description; composers_obj.IPModifiedLog = IP; composers_obj.LastModifiedOnDate = System.DateTime.Now; composers_obj.LastModifiedByUserId = new Guid(UserId); composers_obj.Status = Status; int i = dbContext.SaveChanges(); return i; } }
public int UpdateSortKey(string UserId, int ComposerId, int ListOrder) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Composers composers_obj = dbContext.Media_Composers.Single(x => x.ComposerId == ComposerId); composers_obj.IPModifiedLog = IP; composers_obj.LastModifiedByUserId = new Guid(UserId); composers_obj.LastModifiedOnDate = System.DateTime.Now; composers_obj.ListOrder = ListOrder; int i = dbContext.SaveChanges(); return i; } }
public int Update(int TypeId, string UserId, string TypeName, string TypeExt, string TypePath, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; //Media_Types type_obj = (from x in dbContext.Media_Types where x.TypeId == TypeId select x).First(); Media_Types type_obj = dbContext.Media_Types.Single(x => x.TypeId == TypeId); type_obj.TypeName = TypeName; type_obj.TypeExt = TypeExt; type_obj.TypePath = TypePath; type_obj.Description = Description; type_obj.IPModifiedLog = IP; type_obj.ModifiedDate = System.DateTime.Now; type_obj.LastModifiedByUserId = new Guid(UserId); type_obj.Status = Status; int i = dbContext.SaveChanges(); return i; } }
public Media_PlayLists GetDetails(int idx) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_PlayLists playLists_obj = dbContext.Media_PlayLists.Where(x => x.PlayListId == idx).FirstOrDefault(); return playLists_obj; } }
public int Update(int ArtistId, string UserId, string ArtistName, string FrontImage, string MainImage, string Description, string Status) { using (MediaEntities dbContext = new MediaEntities()) { string Alias = StringUtils.GenerateFriendlyString(ArtistName); dbContext.CommandTimeout = Settings.CommandTimeout; Media_Artists artists_obj = dbContext.Media_Artists.Single(x => x.ArtistId == ArtistId); artists_obj.ArtistName = ArtistName; artists_obj.Alias = Alias; artists_obj.FrontImage = FrontImage; artists_obj.MainImage = MainImage; artists_obj.Description = Description; artists_obj.IPLastUpdate = IP; artists_obj.LastModifiedDate = System.DateTime.Now; artists_obj.LastModifiedByUserId = new Guid(UserId); artists_obj.Status = Status; int i = dbContext.SaveChanges(); return i; } }
public Media_Composers GetDetails(int idx) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Composers composers_obj = dbContext.Media_Composers.Where(x => x.ComposerId == idx).FirstOrDefault(); return composers_obj; } }
public int UpdateSortKey(string UserId, int AlbumId, int SortKey) { using (MediaEntities dbContext = new MediaEntities()) { dbContext.CommandTimeout = Settings.CommandTimeout; Media_Albums album_obj = dbContext.Media_Albums.Single(x => x.AlbumId == AlbumId); album_obj.IPLastUpdate = IP; album_obj.LastModifiedByUserId = new Guid(UserId); album_obj.LastModifiedOnDate = System.DateTime.Now; album_obj.SortKey = SortKey; int i = dbContext.SaveChanges(); return i; } }