public IReadOnlyCollection <Note> GetNote(int id) { IReadOnlyCollection <Note> NoteCollection = default(IReadOnlyCollection <Note>); IList <Note> NoteList = new List <Note>(); NoteSet resultNoteSet = null; try { using (var entities = new DbMovieNetEntities()) { resultNoteSet = entities.NoteSets.Where(note => note.Id == id).FirstOrDefault(); } NoteList.Add(new Note { ScoreGetSet = resultNoteSet.Score, CommentGetSet = resultNoteSet.Comment, Movie_idGetSet = resultNoteSet.Movie_Id }); } catch (SqlException ex) { NewMethodException(ex); } return(NoteCollection = new ReadOnlyCollection <Note>(NoteList)); }
public IReadOnlyCollection <Note> FindNotesOfUser(int idUser) { IReadOnlyCollection <Note> FindNoteUserCollection = default(IReadOnlyCollection <Note>); IList <Note> FindNoteUserList = new List <Note>(); NoteSet resultFindUserNoteSet = null; try { using (DbMovieNetEntities entities = new DbMovieNetEntities()) { resultFindUserNoteSet = (from nt in entities.NoteSets where nt.UserSet.Id == idUser select nt).FirstOrDefault(); } FindNoteUserList.Add(new Note { ScoreGetSet = resultFindUserNoteSet.Score, CommentGetSet = resultFindUserNoteSet.Comment, Movie_idGetSet = resultFindUserNoteSet.Movie_Id, User_idGetSet = resultFindUserNoteSet.User_Id }); } catch (SqlException ex) { NewMethodException(ex); } return(FindNoteUserCollection = new ReadOnlyCollection <Note>(FindNoteUserList)); }