public Dvd HelperSingle(DvdEF dvdEF) { //this is used to convert from dvd to dvdEF because the intervace wants dvds and not dvdEFs Dvd dvds = new Dvd(); Dvd dvd = new Dvd { DvdId = dvdEF.DvdId, Title = dvdEF.Title, DirectorName = dvdEF.Director.DirectorName, ReleaseYear = dvdEF.ReleaseYear, RatingValue = dvdEF.Rating.RatingValue, Notes = dvdEF.Notes }; return(dvd); }
public void Create(Dvd dvd) { DvdEF d = new DvdEF { Notes = dvd.Notes, Title = dvd.Title, ReleaseYear = dvd.ReleaseYear, DvdId = dvd.DvdId }; d.Director = new Director { DirectorName = dvd.DirectorName }; d.Rating = new Rating { RatingValue = dvd.RatingValue }; context.Dvd.Add(d); context.SaveChanges(); }
public void Update(Dvd dvd) { DvdEF d = new DvdEF { Notes = dvd.Notes, Title = dvd.Title, ReleaseYear = dvd.ReleaseYear, DvdId = dvd.DvdId }; d.Director = new Director { DirectorName = dvd.DirectorName }; d.Rating = new Rating { RatingValue = dvd.RatingValue }; var result = context.Dvd.SingleOrDefault(b => b.DvdId == dvd.DvdId); if (result != null) { result = d; context.SaveChanges(); } }