public string ChangeAvailability(int surveyWordID, int adminID)
        {
            using (var context = new FSOSSContext())
            {
                string message = "";
                try
                {
                    // get the current date
                    DateTime dateTime = DateTime.Today;

                    // check if the current word is in use by matching the correct survey word ID and then checking todays day/month/year against the survey word in the database to see if it is in use today
                    var surveyWordAttachToHospital = (from x in context.SurveyWords
                                                      where x.PotentialSurveyWord.survey_word_id == surveyWordID && x.date_used.Day == dateTime.Day && x.date_used.Month == dateTime.Month && x.date_used.Year == dateTime.Year
                                                      select new SurveyWordPOCO()
                    {
                        siteID = x.site_id,
                        surveyWordID = x.survey_word_id,
                        dateUsed = x.date_used
                    }).FirstOrDefault();

                    if (surveyWordAttachToHospital == null)                                                        // if surveyWordAttachToHospital is null, it is not in use and can be disabled or enabled
                    {
                        PotentialSurveyWord potentialSurveyWord = context.PotentialSurveyWords.Find(surveyWordID); // find the survey word by matching it with the survey word ID
                        if (potentialSurveyWord.archived_yn == true)                                               // if the survey word is archived, toggle the archived boolean to false and display the success message that it has been enabled
                        {
                            potentialSurveyWord.archived_yn = false;
                            message = "Successfully enabled the survey word.";
                        }
                        else if (potentialSurveyWord.archived_yn == false) // if the survey word is active, toggle the archived boolean to true and display the success message that it has been disabled
                        {
                            potentialSurveyWord.archived_yn = true;
                            message = "Successfully disabled the survey word.";
                        }
                        // now update the survey word to either enabled or disabled, the modified date and admin ID from the admin that is logged in to the potential survey word table in the database
                        potentialSurveyWord.administrator_account_id = adminID;
                        potentialSurveyWord.date_modified            = DateTime.Now;
                        context.Entry(potentialSurveyWord).Property(y => y.administrator_account_id).IsModified = true;
                        context.Entry(potentialSurveyWord).Property(y => y.archived_yn).IsModified   = true;
                        context.Entry(potentialSurveyWord).Property(y => y.date_modified).IsModified = true;
                        context.SaveChanges();
                    }
                    else
                    {
                        throw new Exception("Unable to change availability of the selected word. Word is currently in use.");
                    }
                }
                catch (Exception e) // catch the error and display it on the page with MessageUserControl
                {
                    throw new Exception(e.Message);
                }
                return(message); // return the success message
            }
        }
Beispiel #2
0
        public string SwitchUnitSatus(int unitID, int admin)
        {
            using (var context = new FSOSSContext())
            {
                string message = "";
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    // Check if the unit exists

                    Unit unit = context.Units.Find(unitID);

                    if (unit.archived_yn == false)
                    {
                        unit.archived_yn = true;
                        message          = "disabled.";
                    }
                    else
                    {
                        unit.archived_yn = false;
                        message          = "enabled";
                    }
                    unit.administrator_account_id = admin;
                    unit.date_modified            = DateTime.Now;
                    context.Entry(unit).Property(y => y.archived_yn).IsModified = true;
                    context.Entry(unit).Property(y => y.administrator_account_id).IsModified = true;
                    context.Entry(unit).Property(y => y.date_modified).IsModified            = true;
                    context.SaveChanges();

                    return("Unit successfully " + message);
                }
                catch (Exception e)
                {
                    throw new Exception("Something went wrong. See " + e.Message);
                }
            }
        } //end of SwitchUnitSatus(disbaling/enabling) unit
Beispiel #3
0
        public string ArchiveGender(int genderID, int admin)
        {
            string result = "";

            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }

                    //If the gender is disabled, enable it; otherwise, disable the gender.
                    Gender gndr = context.Genders.Find(genderID);
                    if (gndr.archived_yn)
                    {
                        gndr.archived_yn = false;
                        result           = "enabled.";
                    }
                    else
                    {
                        gndr.archived_yn = true;
                        result           = "disabled";
                    }
                    gndr.administrator_account_id = admin;
                    gndr.date_modified            = DateTime.Now;
                    context.Entry(gndr).Property(y => y.archived_yn).IsModified = true;
                    context.Entry(gndr).Property(y => y.administrator_account_id).IsModified = true;
                    context.Entry(gndr).Property(y => y.date_modified).IsModified            = true;
                    context.SaveChanges();

                    return("Gender succesfully " + result);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
        public string ArchiveParticipantType(int participantTypeID, int admin)
        {
            string result = "";

            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }

                    //throw new Exception("tried to delete ptid="+ participantTypeID);
                    ParticipantType pt2 = context.ParticipantTypes.Find(participantTypeID);
                    if (pt2.archived_yn)
                    {
                        pt2.archived_yn = false;
                        result          = "enabled.";
                    }
                    else
                    {
                        pt2.archived_yn = true;
                        result          = "disabled";
                    }
                    pt2.administrator_account_id = admin;
                    pt2.date_modified            = DateTime.Now;
                    context.Entry(pt2).Property(y => y.archived_yn).IsModified = true;
                    context.Entry(pt2).Property(y => y.administrator_account_id).IsModified = true;
                    context.Entry(pt2).Property(y => y.date_modified).IsModified            = true;
                    context.SaveChanges();

                    return("Participant Type succesfully " + result);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Beispiel #5
0
        public string ArchiveMeal(int mealID, int admin)
        {
            string result = "";

            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }

                    Meal meal = context.Meals.Find(mealID);
                    if (meal.archived_yn)
                    {
                        meal.archived_yn = false;
                        result           = "enabled.";
                    }
                    else
                    {
                        meal.archived_yn = true;
                        result           = "disabled";
                    }
                    meal.administrator_account_id = admin;
                    meal.date_modified            = DateTime.Now;
                    context.Entry(meal).Property(y => y.archived_yn).IsModified = true;
                    context.Entry(meal).Property(y => y.administrator_account_id).IsModified = true;
                    context.Entry(meal).Property(y => y.date_modified).IsModified            = true;
                    context.SaveChanges();

                    return("Meal succesfully " + result);
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Beispiel #6
0
        public void ContactSurvey(int submittedSurveyID)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    SubmittedSurvey ss = context.SubmittedSurveys.Find(submittedSurveyID);
                    ss.contacted = true;

                    context.Entry(ss).Property(y => y.contacted).IsModified = true;
                    context.SaveChanges();
                }
                catch (Exception e)
                {
                    throw new Exception("Please contact the Administrator with the error message: " + e.Message);
                }
            }
        }
Beispiel #7
0
        public string ArchiveSite(int siteID, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    //If the admin is 0, then display an error message.
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }

                    // Check if the site exists
                    var searchSite = (from x in context.Sites
                                      where x.site_id == siteID
                                      select new SitePOCO()
                    {
                        siteID = x.site_id,
                        siteName = x.site_name,
                        archived_yn = x.archived_yn,
                        dateModified = DateTime.Now
                    }).FirstOrDefault();
                    //Select all the active sites
                    List <Site> lastSite = (from x in context.Sites
                                            where x.archived_yn == false
                                            select x).ToList();
                    if (searchSite == null)
                    {
                        throw new Exception("This site does not exist.");
                    }

                    //If the site is archived, activate it and update the date modified. If the site is not archived, archive it and update the date modified.
                    Site site = context.Sites.Find(siteID);
                    if (site.archived_yn == false)
                    {
                        //If the admin is attempting to disable the last active site in the system, throw an error.
                        if (lastSite.Count() == 1)
                        {
                            throw new Exception("Cannot disable site. There needs to be at least one active site.");
                        }
                        else
                        {
                            site.archived_yn   = true;
                            site.date_modified = DateTime.Now;
                        }
                    }
                    else
                    {
                        site.archived_yn   = false;
                        site.date_modified = DateTime.Now;
                    };
                    context.Entry(site).State = EntityState.Modified;
                    context.SaveChanges();
                    return("Site successfully updated.");
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Beispiel #8
0
        public string UpdateSite(int siteID, string siteName, int admin)
        {
            using (var context = new FSOSSContext())
            {
                Regex  valid   = new Regex("^[a-zA-Z '.]+$");
                string message = "";
                try
                {
                    //If this new site name is an empty string or null, then display an error message.
                    if (siteName == "" || siteName == null)
                    {
                        throw new Exception("Please enter a site name. Field cannot be empty.");
                    }
                    //If the new site name is more than 100 characters long, then display an error message.
                    if (siteName.Length > 100)
                    {
                        throw new Exception("The site name can only be 100 characters long.");
                    }
                    //Check if the name already exists in the database.
                    var siteList = from x in context.Sites
                                   where x.site_name.ToLower().Equals(siteName.ToLower()) &&
                                   !x.archived_yn
                                   select new SitePOCO()
                    {
                        siteName = x.site_name
                    };
                    var GoneSiteList = from x in context.Sites
                                       where x.site_name.ToLower().Equals(siteName.ToLower()) &&
                                       x.archived_yn
                                       select new SitePOCO()
                    {
                        siteName = x.site_name
                    };
                    if (siteList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The site \"" + siteName.ToLower() + "\" already exists. Please enter a new site.");
                    }
                    else if (GoneSiteList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The site \"" + siteName.ToLower() + "\" already exists and is Archived. Please enter a new site.");
                    }
                    //Select all the information about a site, where the siteID matches the siteID passed in from the POCO.
                    var exists = (from x in context.Sites
                                  where x.site_id == siteID
                                  select x);
                    //If exists does not return anything, throw an exception.
                    if (exists == null)
                    {
                        throw new Exception("This site does not exist.");
                    }
                    //If characters not approved by the Regex (defined by valid) are entered, then display an error message.
                    if (!(valid.IsMatch(siteName)))
                    {
                        throw new Exception("Please enter only alphabetical letters.");
                    }
                    else
                    {
                        Site updateSite = context.Sites.Find(siteID);
                        updateSite.site_name                = siteName.Trim();
                        updateSite.date_modified            = DateTime.Now;
                        updateSite.administrator_account_id = admin;

                        context.Entry(updateSite).State = EntityState.Modified;
                        context.SaveChanges();
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
                return(message);
            } //context
        }     //update site
Beispiel #9
0
        public string UpdateParticipantType(int mealID, string mealName, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (mealName == "" || mealName == null)
                    {
                        throw new Exception("Please enter a Meal Name");
                    }
                    //add duplicate check
                    var mealList = from x in context.Meals
                                   where x.meal_name.ToLower().Equals(mealName.ToLower()) &&
                                   x.meal_id != mealID && !x.archived_yn
                                   select new MealPOCO()
                    {
                        mealName = x.meal_name
                    };


                    var GoneMealList = from x in context.Meals
                                       where x.meal_name.ToLower().Equals(mealName.ToLower()) &&
                                       x.meal_id != mealID && x.archived_yn
                                       select new MealPOCO()
                    {
                        mealName = x.meal_name
                    };
                    if (mealList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The meal \"" + mealName.ToLower() + "\" already exists. Please enter a new meal.");
                    }
                    else if (GoneMealList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The meal \"" + mealName.ToLower() + "\" already exists and is Archived. Please enter a new meal.");
                    }

                    else
                    {
                        Meal meal = context.Meals.Find(mealID);
                        meal.meal_name                = mealName;
                        meal.date_modified            = DateTime.Now;
                        meal.administrator_account_id = admin;

                        context.Entry(meal).Property(y => y.meal_name).IsModified                = true;
                        context.Entry(meal).Property(y => y.date_modified).IsModified            = true;
                        context.Entry(meal).Property(y => y.administrator_account_id).IsModified = true;

                        context.SaveChanges();

                        return("Meal successfully updated.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
Beispiel #10
0
        public string UpdateUnit(int unitID, string unitNumber, int admin)
        {
            using (var context = new FSOSSContext())
            {
                Regex  validUnit = new Regex("^[0-9]{1,3}[a-zA-Z/s]{1,47}|[a-zA-Z/s]{1,50}$");
                string message   = "";

                try
                {
                    if (admin == 0) //check to see if admin is logged in
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (unitNumber == "" || unitNumber == null) // check to see if unit number text box is empty
                    {
                        throw new Exception("Please enter a Unit Number");
                    }

                    if (unitNumber.Length < 2 || unitNumber.Length > 50) // check to see the minimum and maximum length of inserted characters.
                    {
                        throw new Exception("Input must be between 2 charaters to 50 chatecters long.");
                    }

                    if (!validUnit.IsMatch(unitNumber))// check to see if the updated number is entered is consistent with the valid pattern set.
                    {
                        throw new Exception("Invalid input pattern. Correct pattern (up to 3 digits followed by upto 47 alphabets) OR (up to 50 alphabets long only)without special characters.");
                    }



                    //check active units
                    var unitExist = from x in context.Units
                                    where x.unit_number.ToUpper() == unitNumber.ToUpper() &&
                                    x.archived_yn == false
                                    select new UnitsPOCO()
                    {
                        unitNumber = x.unit_number,
                    };
                    //check Archived units
                    var unitExistsInArchived = from x in context.Units
                                               where x.unit_number.ToUpper() == unitNumber.ToUpper() &&
                                               x.archived_yn == true
                                               select new UnitsPOCO()
                    {
                        unitNumber = x.unit_number,
                    };
                    if (unitExist.Count() > 0) //if new unit exists in active so, return an error message
                    {
                        throw new Exception("The unit \"" + unitNumber.ToUpper() + "\" already exists. Please enter a new Unit.");
                    }

                    if (unitExistsInArchived.Count() > 0)//if new unit exists in archived so, return an error message

                    {
                        throw new Exception("The unit \"" + unitNumber.ToUpper() + "\" exists in archived. Check in archived in order to activate unit. ");
                    }


                    else
                    {
                        Unit unitToUpdate = context.Units.Find(unitID);
                        unitToUpdate.administrator_account_id = admin;
                        unitToUpdate.unit_number          = unitNumber;
                        unitToUpdate.date_modified        = DateTime.Now;
                        context.Entry(unitToUpdate).State = EntityState.Modified;

                        context.SaveChanges();
                        message = " Unit " + unitNumber + " updated.";
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
                return(message);
            }
        }//end of update Unit
Beispiel #11
0
        public string UpdateAgeRange(int ageRangeID, string ageRangeDescription, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (ageRangeDescription == "" || ageRangeDescription == null)
                    {
                        throw new Exception("Please enter an age range description");
                    }
                    //add duplicate check
                    var ageList = from x in context.AgeRanges
                                  where x.age_range_description.ToLower().Equals(ageRangeDescription.ToLower()) &&
                                  x.age_range_id != ageRangeID && !x.archived_yn
                                  select new AgeRangePOCO()
                    {
                        ageRangeDescription = x.age_range_description
                    };


                    var GoneageList = from x in context.AgeRanges
                                      where x.age_range_description.ToLower().Equals(ageRangeDescription.ToLower()) &&
                                      x.age_range_id != ageRangeID && x.archived_yn
                                      select new AgeRangePOCO()
                    {
                        ageRangeDescription = x.age_range_description
                    };
                    if (ageList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The age range \"" + ageRangeDescription.ToLower() + "\" already exists. Please enter a new age range.");
                    }
                    else if (GoneageList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The age range \"" + ageRangeDescription.ToLower() + "\" already exists and is Archived. Please enter a new age range.");
                    }

                    else
                    {
                        AgeRange age = context.AgeRanges.Find(ageRangeID);
                        age.age_range_description    = ageRangeDescription;
                        age.date_modified            = DateTime.Now;
                        age.administrator_account_id = admin;

                        context.Entry(age).Property(y => y.age_range_description).IsModified    = true;
                        context.Entry(age).Property(y => y.date_modified).IsModified            = true;
                        context.Entry(age).Property(y => y.administrator_account_id).IsModified = true;

                        context.SaveChanges();

                        return("Age Range successfully updated.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
        public string UpdateWord(string surveyWord, int surveyWordID, int adminID)
        {
            using (var context = new FSOSSContext())
            {
                string message = "";
                try
                {
                    surveyWord = surveyWord.ToLower().Trim(); // trim the spaces and covert the updated survey word to lowercase
                    Regex validWord = new Regex("^[a-zA-Z]+$");

                    // gets a list of survey words where the surveyWord is matching an existing word
                    var potentialSurveyWordList = from x in context.PotentialSurveyWords
                                                  where x.survey_access_word.ToLower().Equals(surveyWord)
                                                  select new PotentialSurveyWordPOCO()
                    {
                        surveyWord = x.survey_access_word
                    };

                    if (potentialSurveyWordList.Count() > 0) // if a survey word was found display an error that the word already exists
                    {
                        throw new Exception("The word \"" + surveyWord + "\" already exists. Please update to a different word.");
                    }
                    else
                    {
                        if (surveyWord == "" || surveyWord == null) // if no survey word was entered, display an error
                        {
                            throw new Exception("Edit field cannot be blank. You must enter a word between 4 to 8 characters in length.");
                        }
                        else if (!validWord.IsMatch(surveyWord)) // if the survey word entered is not valid (no special characters, spaces, or numbers), display an error
                        {
                            throw new Exception("Please enter only alphabetical letters and no spaces.");
                        }
                        else if (surveyWord.Length < 4 || surveyWord.Length > 8) // if the survey word is not the correct length (between 4 and 8 characters), display an error
                        {
                            throw new Exception("Updated survey word must be between 4 to 8 characters in length.");
                        }
                        else
                        {
                            bool inUse = false;

                            // gets a list of survey word IDs and the date that the words are in use
                            var surveyWordList = (from x in context.SurveyWords
                                                  select new SurveyWordPOCO
                            {
                                dateUsed = x.date_used,
                                surveyWordID = x.survey_word_id
                            }).ToList();


                            foreach (SurveyWordPOCO item in surveyWordList) // loop through the survey word list and match the survey word ID and the date used to todays date
                            {
                                if (item.surveyWordID == surveyWordID && item.dateUsed.Day == DateTime.Today.Day)
                                {
                                    inUse = true; // toggle inUse to true if the survey word is in use today
                                    break;
                                }
                            }

                            if (validWord.IsMatch(surveyWord) && inUse == false) // if the survey word is not in use today, then update the survey word, the modified date and user ID from the user that is logged in to the potential survey word table in the database
                            {
                                var wordToUpdate = context.PotentialSurveyWords.Find(surveyWordID);
                                wordToUpdate.administrator_account_id = adminID;
                                wordToUpdate.survey_access_word       = surveyWord.Trim();
                                wordToUpdate.date_modified            = DateTime.Now;
                                context.Entry(wordToUpdate).Property(y => y.administrator_account_id).IsModified = true;
                                context.Entry(wordToUpdate).Property(y => y.survey_access_word).IsModified       = true;
                                context.Entry(wordToUpdate).Property(y => y.date_modified).IsModified            = true;
                                context.SaveChanges();

                                message = "The survey word has been updated to \"" + surveyWord + "\"."; // update message to display a success message
                            }
                            else
                            {
                                throw new Exception("Unable to update the selected word. Word is currently in use.");
                            }
                        }
                    }
                }
                catch (Exception e) // catch the error and display it on the page with MessageUserControl
                {
                    throw new Exception(e.Message);
                }
                return(message); // return the success message
            }
        }
Beispiel #13
0
        public string UpdateGender(int genderID, string genderDescription, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    //If the gender description is an empty string or is null, then display an error message.
                    if (genderDescription == "" || genderDescription == null)
                    {
                        throw new Exception("Please enter a Participant Type Description");
                    }
                    //Check for duplicates
                    var genderList = from x in context.Genders
                                     where x.gender_description.ToLower().Equals(genderDescription.ToLower()) &&
                                     x.gender_id != genderID &&
                                     !x.archived_yn
                                     select new GenderPOCO()
                    {
                        genderDescription = x.gender_description
                    };


                    var GoneGenderList = from x in context.Genders
                                         where x.gender_description.ToLower().Equals(genderDescription.ToLower()) &&
                                         x.gender_id != genderID && x.archived_yn
                                         select new GenderPOCO()
                    {
                        genderDescription = x.gender_description
                    };
                    if (genderList.Count() > 0) //If duplicates exist, return an error message.
                    {
                        throw new Exception("The participant type \"" + genderDescription.ToLower() + "\" already exists. Please enter a new participant type.");
                    }
                    else if (GoneGenderList.Count() > 0) //If duplicates exist, return an error message.
                    {
                        throw new Exception("The participant type \"" + genderDescription.ToLower() + "\" already exists and is Archived. Please enter a new  gender.");
                    }
                    //Update the gender description, date modified, and administrator account id
                    else
                    {
                        Gender gndr = context.Genders.Find(genderID);
                        gndr.gender_description       = genderDescription;
                        gndr.date_modified            = DateTime.Now;
                        gndr.administrator_account_id = admin;

                        context.Entry(gndr).Property(y => y.gender_description).IsModified       = true;
                        context.Entry(gndr).Property(y => y.date_modified).IsModified            = true;
                        context.Entry(gndr).Property(y => y.administrator_account_id).IsModified = true;

                        context.SaveChanges();

                        return("Gender successfully updated.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }
        public string UpdateParticipantType(int participantTypeID, string participantTypeDescription, int admin)
        {
            using (var context = new FSOSSContext())
            {
                try
                {
                    if (admin == 0)
                    {
                        throw new Exception("Can't let you do that. You're not logged in.");
                    }
                    if (participantTypeDescription == "" || participantTypeDescription == null)
                    {
                        throw new Exception("Please enter a Participant Type Description");
                    }
                    //add duplicate check
                    var participantTypeList = from x in context.ParticipantTypes
                                              where x.participant_description.ToLower().Equals(participantTypeDescription.ToLower()) &&
                                              x.participant_type_id != participantTypeID &&
                                              !x.archived_yn
                                              select new ParticipantTypePOCO()
                    {
                        participantTypeDescription = x.participant_description
                    };


                    var GoneparticipantTypeList = from x in context.ParticipantTypes
                                                  where x.participant_description.ToLower().Equals(participantTypeDescription.ToLower()) &&
                                                  x.participant_type_id != participantTypeID &&
                                                  x.archived_yn
                                                  select new ParticipantTypePOCO()
                    {
                        participantTypeDescription = x.participant_description
                    };
                    if (participantTypeList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The participant type \"" + participantTypeDescription.ToLower() + "\" already exists. Please enter a new participant type.");
                    }
                    else if (GoneparticipantTypeList.Count() > 0) //if so, return an error message
                    {
                        throw new Exception("The participant type \"" + participantTypeDescription.ToLower() + "\" already exists and is Archived. Please enter a new participant type.");
                    }

                    else
                    {
                        ParticipantType pt2 = context.ParticipantTypes.Find(participantTypeID);
                        pt2.participant_description  = participantTypeDescription;
                        pt2.date_modified            = DateTime.Now;
                        pt2.administrator_account_id = admin;

                        context.Entry(pt2).Property(y => y.participant_description).IsModified  = true;
                        context.Entry(pt2).Property(y => y.date_modified).IsModified            = true;
                        context.Entry(pt2).Property(y => y.administrator_account_id).IsModified = true;

                        context.SaveChanges();

                        return("Participant Type successfully updated.");
                    }
                }
                catch (Exception e)
                {
                    throw new Exception(e.Message);
                }
            }
        }