Beispiel #1
0
        //Page 154 ToDo: Test Enforce One to One filepath to recording object
        public IEnumerable <ValidationResult> Validate(ValidationContext validationContext)
        {
            var db = new BMContext();

            #region Enforce one file per recording object

            var existingPath = db.Recordings
                               .Where(r => (r.FolderPath + r.FileName)
                                      .Trim().ToLower()
                                      == (FolderPath + FileName)
                                      .Trim().ToLower()
                                      ).SingleOrDefault();
            if (existingPath != null)
            {
                yield return(new ValidationResult
                             (
                                 "This file name has already been assigned.",
                                 new[] { "FolderPath", "FileName" }
                             ));
            }
            #endregion
        }
Beispiel #2
0
 public Recording(int songID = -1)
 {
     SongID = songID;
     Song   = new BMContext().Songs.Find(songID);
 }