public static void updateReviewedStatus(bool isReviewed, int CWID) { try { using (var db = new HearMyNameEntities()) { StudentRecording originalRecord = db.StudentRecordings.Find(CWID); originalRecord.isReviewed = isReviewed; db.SaveChanges(); } } catch (Exception ex) { } }
//copy the recording from the project directory to the file server (Waxmyrtle) and delete the current project directory copy. //save/update db record for the student. protected static string updateDatabase(int recordingID, string email, string pronounciation, string studentSystemName, string NTID, string preferredName, string currentUserID) { int numericCWID = Int32.Parse(currentUserID); try { using (var db = new HearMyNameEntities()) { string newRecodingID = string.Empty; if (recordingID > 0) //a record exists, this is an UPdate { StudentRecording originalRecord = db.StudentRecordings.Find(recordingID); originalRecord.StudentPreferredName = preferredName; originalRecord.Pronounciation = pronounciation; AppEvent newAppEvent = new AppEvent { RecordingID = recordingID, ActionPerformed = "Updated recording", NewStatus = "NotApproved", PerformedBy = 1, PerformedOn = DateTime.Now }; db.AppEvents.Add(newAppEvent); } else //this is a new record, inserrrrt! { StudentRecording newRecord = new StudentRecording { StudentCWID = int.Parse(currentUserID), StudentNTID = NTID, StudentName = studentSystemName, StudentPreferredName = string.IsNullOrEmpty(preferredName) ? " " : preferredName, Pronounciation = string.IsNullOrEmpty(pronounciation) ? " " : pronounciation, StudentEmail = email, CreatedBy = currentUserID, CreatedOn = DateTime.Now }; AppEvent newAppEvent = new AppEvent { ActionPerformed = "Created a new recording", NewStatus = "NotApproved", PerformedBy = 1, PerformedOn = DateTime.Now }; newRecord.AppEvents = new List <AppEvent>(); newRecord.AppEvents.Add(newAppEvent); db.StudentRecordings.Add(newRecord); } db.SaveChanges(); StudentRecording previousRecord = db.StudentRecordings.First(A => A.StudentCWID == numericCWID); return(previousRecord.ID.ToString()); } } catch (Exception exe) { LogHelper.LogError(exe.ToString()); return(string.Empty); } }