コード例 #1
0
        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);
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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();
            }
        }