/// <summary>
 /// Deprecated Method for adding a new object to the Media_Albums EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToMedia_Albums(Media_Albums media_Albums)
 {
     base.AddObject("Media_Albums", media_Albums);
 }
 /// <summary>
 /// Create a new Media_Albums object.
 /// </summary>
 /// <param name="typeId">Initial value of the TypeId property.</param>
 /// <param name="albumId">Initial value of the AlbumId property.</param>
 /// <param name="albumName">Initial value of the AlbumName property.</param>
 /// <param name="alias">Initial value of the Alias property.</param>
 /// <param name="iPLog">Initial value of the IPLog property.</param>
 public static Media_Albums CreateMedia_Albums(global::System.Int32 typeId, global::System.Int32 albumId, global::System.String albumName, global::System.String alias, global::System.String iPLog)
 {
     Media_Albums media_Albums = new Media_Albums();
     media_Albums.TypeId = typeId;
     media_Albums.AlbumId = albumId;
     media_Albums.AlbumName = albumName;
     media_Albums.Alias = alias;
     media_Albums.IPLog = iPLog;
     return media_Albums;
 }
        //INSERT- UPDATE - DELETE 
        public int Insert(string UserId, int TypeId, string AlbumName, string FrontImage, string MainImage, string Description, string Status)
        {
            int returnValue = 0;
            using (MediaEntities dbContext = new MediaEntities())
            {
                using (System.Transactions.TransactionScope transcope = new System.Transactions.TransactionScope())
                {
                    string Alias = StringUtils.GenerateFriendlyString(AlbumName);
                    dbContext.CommandTimeout = Settings.CommandTimeout;
                    System.Nullable<Int32> SortKey = (from u in dbContext.Media_Albums select u.SortKey).DefaultIfEmpty(0).Max() + 1;

                    Media_Albums entity = new Media_Albums();
                    entity.TypeId = TypeId;
                    entity.AlbumName = AlbumName;
                    entity.Alias = Alias;
                    entity.FrontImage = FrontImage;
                    entity.MainImage = MainImage;
                    entity.Description = Description;
                    entity.SortKey = (SortKey == null ? 1 : SortKey);
                    entity.IPLog = IP;
                    entity.CreatedByUserId = new Guid(UserId);
                    entity.CreatedOnDate = System.DateTime.Now;
                    entity.Status = Status;

                    dbContext.AddToMedia_Albums(entity);
                    returnValue = dbContext.SaveChanges();
                    transcope.Complete();
                }                
            }
            return returnValue;
        }