//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); } }