// ADD the next Disc to a specific case/box public static Disc AddNextDisc(MyDVDsContext context, int boxnum, int casenum) { Case ca = new Case(); Disc di = new Disc(); // get the box specific case ca = GetCase(context, boxnum, casenum); // set the next disc # di.DiscNumber = GetNextDiscNumber(ca); // set fields di.Notes = ""; di.IsACollection = false; di.Title = ""; // set parent nav di.CaseId = ca.Id; ca.TotalDiscs++; di.Case = ca; // add the new disc to the case ca.Discs.Add(di); context.SaveChanges(); return(di); }
public static DVDIcon AddDVDIcon(MyDVDsContext context, DVDIcon newdvi) { // add it context.DVDIcons.Add(newdvi); context.SaveChanges(); newdvi = GetDVDIcon(context, newdvi.Id); return(newdvi); }
public static DVDIcon UpdateDVDIcon(MyDVDsContext context, DVDIcon newdvi) { var olddvi = GetDVDIcon(context, newdvi.Id); context.Entry(olddvi).CurrentValues.SetValues(newdvi); context.SaveChanges(); newdvi = GetDVDIcon(context, newdvi.Id); return(newdvi); }
public static Rating UpdateRating(MyDVDsContext context, Rating newrating) { var oldrating = GetRating(context, newrating.Id); context.Entry(oldrating).CurrentValues.SetValues(newrating); context.SaveChanges(); newrating = GetRating(context, newrating.Id); return(newrating); }
public static Rating AddRating(MyDVDsContext context, Rating newRtg) { // add it context.Ratings.Add(newRtg); context.SaveChanges(); newRtg = GetRating(context, newRtg.Id); return(newRtg); }
public static Genre AddGenre(MyDVDsContext context, Genre newgnr) { // add it context.Genres.Add(newgnr); context.SaveChanges(); newgnr = GetGenre(context, newgnr.Id); return(newgnr); }
public static Genre UpdateGenre(MyDVDsContext context, Genre newgenre) { var oldgenre = GetGenre(context, newgenre.Id); context.Entry(oldgenre).CurrentValues.SetValues(newgenre); context.SaveChanges(); newgenre = GetGenre(context, newgenre.Id); return(newgenre); }
// ADD the next Case to a specific box public static Case AddNextCase(MyDVDsContext context, int boxnum) { StorageBox sb = new StorageBox(); Case ca = new Case(); // get the box sb = GetBox(context, boxnum); // set next case number ca.CaseNumber = GetNextCaseNumber(sb); // set fields ca.CaseType = sb.BoxType; ca.Notes = ""; ca.IsABoxset = false; ca.Title = ""; // set parent nav ca.StorageBoxId = sb.Id; sb.TotalCases++; ca.StorageBox = sb; // set lookup navs switch (ca.CaseType) { case "CD": ca.DVDIconId = CDCASEICON; break; case "DVD": ca.DVDIconId = DVDCASEICON; break; default: ca.DVDIconId = CDCASEICON; break; } ca.DVDIcon = GetDVDIcon(context, ca.DVDIconId); // add the new case to the box sb.Cases.Add(ca); context.SaveChanges(); return(ca); }
// ADD a new Box - no related records public static StorageBox AddABox(MyDVDsContext context, string boxtype) { StorageBox sb = new StorageBox(); // get next box # sb.BoxNumber = GetNextBoxNumber(context); // init fields sb.BoxType = boxtype; sb.Notes = ""; // add it context.StorageBoxes.Add(sb); context.SaveChanges(); return(sb); }
// ADD the next Content to a specific disc/case/box public static Content AddNextContent(MyDVDsContext context, int boxnum, int casenum, int discnum) { Disc di = new Disc(); Content co = new Content(); // get the disc di = GetDisc(context, boxnum, casenum, discnum); // get next content # co.ContentNumber = GetNextContentNumber(di); // set fields co.Notes = ""; co.Title = ""; co.Year = ""; co.Cast = ""; co.Director = ""; // set parent nav co.DiscId = di.Id; di.TotalContents++; co.Disc = di; // set lookup navs co.GenreId = 1; co.Genre = GetGenre(context, co.GenreId); co.RatingId = 1; co.Rating = GetRating(context, co.RatingId); co.DVDIconId = DVDDISCICON; co.DVDIcon = GetDVDIcon(context, co.DVDIconId); // add the new content to the disc di.Contents.Add(co); context.SaveChanges(); return(co); }
public static int DeleteRating(MyDVDsContext context, Rating Rtg) { context.Entry(Rtg).State = EntityState.Deleted; return(context.SaveChanges()); }
public static int DeleteGenre(MyDVDsContext context, Genre gnr) { context.Entry(gnr).State = EntityState.Deleted; return(context.SaveChanges()); }