public int Update()
        {
            try
            {
                using (MusicEntities dc = new MusicEntities())
                {
                    //Retrieve the record from the DB
                    tblComposer composer = dc.tblComposers.FirstOrDefault(c => c.Id == this.Id);

                    //Update the properties
                    composer.FirstName  = this.FirstName;
                    composer.LastName   = this.LastName;
                    composer.GenderId   = this.GenderId;
                    composer.LocationId = this.LocationId;
                    composer.RaceId     = this.RaceId;
                    composer.Bio        = this.Bio;

                    //Save the changes
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Insert the composer into the db, and generate a new Id for it.
        public int Insert()
        {
            try
            {
                using (MusicEntities dc = new MusicEntities())
                {
                    //Create a new Id
                    this.Id = Guid.NewGuid();

                    //Set the properties
                    tblComposer composer = new tblComposer
                    {
                        Id         = this.Id,
                        FirstName  = this.FirstName,
                        LastName   = this.LastName,
                        GenderId   = this.GenderId,
                        LocationId = this.LocationId,
                        RaceId     = this.RaceId,
                        Bio        = this.Bio
                    };

                    //Add it to the table and save changes
                    dc.tblComposers.Add(composer);
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void DeleteTest()
        {
            using (MusicEntities dc = new MusicEntities())
            {
                tblComposer composer = dc.tblComposers.FirstOrDefault(a => a.FirstName == "PL Test First Name");

                dc.tblComposers.Remove(composer);

                dc.SaveChanges();

                tblComposer retrievedComposer = dc.tblComposers.FirstOrDefault(a => a.FirstName == "PL Test First Name");

                Assert.IsNull(retrievedComposer);
            }
        }
        public void UpdateTest()
        {
            using (MusicEntities dc = new MusicEntities())
            {
                tblComposer composer = dc.tblComposers.FirstOrDefault(a => a.FirstName == "PL Test First Name");

                composer.LastName = "PL Updated Test Last Name";

                dc.SaveChanges();

                tblComposer retrievedComposer = dc.tblComposers.FirstOrDefault(a => a.FirstName == "PL Test First Name");

                Assert.IsNotNull(retrievedComposer);
            }
        }
        public int Delete()
        {
            try
            {
                using (MusicEntities dc = new MusicEntities())
                {
                    //Retrieve it from the DB
                    tblComposer composer = dc.tblComposers.FirstOrDefault(c => c.Id == this.Id);

                    //Remove the composer
                    dc.tblComposers.Remove(composer);

                    //Save the changes
                    return(dc.SaveChanges());
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        //Retrieve the performance from the database with this Id
        public void LoadByName()
        {
            try
            {
                using (MusicEntities dc = new MusicEntities())
                {
                    //Retrieve from the db
                    tblComposer composer = dc.tblComposers.FirstOrDefault(p => p.LastName == this.LastName);

                    //Set this performance's properties
                    this.Id        = composer.Id;
                    this.FirstName = composer.FirstName;
                    this.LastName  = composer.LastName;
                    this.Bio       = composer.Bio;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void InsertTest()
        {
            using (MusicEntities dc = new MusicEntities())
            {
                tblComposer composer = new tblComposer();
                composer.Id         = Guid.NewGuid();
                composer.FirstName  = "PL Test First Name";
                composer.LastName   = "PL Test Last Name";
                composer.GenderId   = dc.tblGenders.FirstOrDefault(p => p.Description == "Male").Id;
                composer.RaceId     = dc.tblRaces.FirstOrDefault(p => p.Description == "Other").Id;
                composer.LocationId = dc.tblLocations.FirstOrDefault(p => p.Description == "Wisconsin").Id;
                composer.Bio        = "PL Test Bio";

                dc.tblComposers.Add(composer);

                dc.SaveChanges();

                tblComposer retrievedComposer = dc.tblComposers.FirstOrDefault(a => a.GenderId == composer.GenderId && a.RaceId == composer.RaceId && a.LocationId == composer.LocationId);

                Assert.AreEqual(composer.Id, retrievedComposer.Id);
            }
        }