コード例 #1
0
 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)
     {
     }
 }
コード例 #2
0
        protected void LoadData()
        {
            if (isNSO)
            {
                btnUpdate.Value = "Save and Log Out";
            }

            int numericCWID = Int32.Parse(CWID);

            hdrMainHeader.InnerText = Name;
            using (var db = new HearMyNameEntities())
            {
                if (db.StudentRecordings.FirstOrDefault(A => A.StudentCWID == numericCWID) != null) //this is an update
                {
                    StudentRecording previousRecord = db.StudentRecordings.First(A => A.StudentCWID == numericCWID);
                    if (!IsPostBack)
                    {
                        txtPreferredName.Value = previousRecord.StudentPreferredName.Replace("(student)", "");
                        txtPhoneticName.Value  = previousRecord.Pronounciation;
                        if (audioPlayer.Src == null || audioPlayer.Src.Contains("Default"))
                        {
                            audioPlayer.Attributes["src"] = $"~/userfiles/converted/{CWID}.mp3?noCache={new Random().Next(0, 1000).ToString()}"; //the NoCache parameter just makes it so that the name looks different to the browser so it doesn't cache it.
                        }
                        else
                        {
                            playButton.Disabled = true;
                        }
                    }

                    recordingID          = previousRecord.ID;
                    hdnRecordingID.Value = recordingID.ToString();
                }
                else //This is a recording for a student has never done this before
                {
                    txtPreferredName.Value = Name;
                    playButton.Disabled    = true;
                    hdnRecordingID.Value   = "0";
                }
            }
        }
コード例 #3
0
        //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);
            }
        }