//INSERT- UPDATE - DELETE public int Insert(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; System.Nullable <Int32> ListOrder = (from u in dbContext.Media_Artists select u.ListOrder).DefaultIfEmpty(0).Max() + 1; Media_Artists artists_obj = new Media_Artists(); artists_obj.ArtistName = ArtistName; artists_obj.Alias = Alias; artists_obj.FrontImage = FrontImage; artists_obj.MainImage = MainImage; artists_obj.Description = Description; artists_obj.ListOrder = (ListOrder == null ? 1 : ListOrder); artists_obj.IPLog = IP; artists_obj.CreatedOnDate = System.DateTime.Now; artists_obj.CreatedByUserId = new Guid(UserId); artists_obj.Status = Status; dbContext.AddToMedia_Artists(artists_obj); int i = dbContext.SaveChanges(); return(i); } }