public object Create(string Id)
        {
            ViewData["Title"] = "Create Preference";
            ViewData["Message"] = "Create a Preference";
            if (string.IsNullOrEmpty(Id)) {
                return RedirectToAction("Index", "Professor");

            }
            int profId;
            try {
                profId = Convert.ToInt32(Id);
            } catch (Exception)   //not an integer
            {
                return RedirectToAction("Index", "Professor");
            }
            Professor professor = new ProfessorProvider().GetProfessorByID(profId);
            if (professor == null) {
                return RedirectToAction("Index", "Professor");
            }
            var ProfPrefs = (new PreferencesProvider().GetAllPreferencesByProfId(profId));
            var settings = new Settings();
            int lookFor = settings.NumberOfPreferencesPerProfessor;
            while (true)
            {
                int lookFor1 = lookFor;
                if (ProfPrefs.Where(s => s.Weight == lookFor1).Count() == 0)
                {
                    break;
                }
                lookFor--;
                if (lookFor == 0)
                {
                    break;
                }
            }
            int weight = lookFor;
            var preference = new Preference
                             	{
                             		Id = { Professor = professor },
                             		Weight = weight
                             	};
            PrepareCoursesList(preference);
            ViewData["ProfId"] = preference.Id.Professor.ProfId;
            return View(preference);
        }
Esempio n. 2
0
        public void SettingsConstructorTest()
        {
            System.DateTime constructorStartTime = System.DateTime.Now;

            //Parameter Definitions

            //Default Value Test
             Settings settings = new Settings();
            Assert.AreEqual(String.Empty, String.Empty, "ClassLibrary.Settings.SettingsConstructor constructor default test failed");

            //Min Test

             Settings settings = new Settings();
            Assert.AreEqual(String.Empty, String.Empty, "ClassLibrary.Settings.SettingsConstructor constructor min test failed");

            //Max Test

             Settings settings = new Settings();
            Assert.AreEqual(String.Empty, String.Empty, "ClassLibrary.Settings.SettingsConstructor constructor max test failed");

            //Null Test

             Settings settings = new Settings();
            Assert.AreEqual(String.Empty, String.Empty, "ClassLibrary.Settings.SettingsConstructor constructor null test failed");

            System.TimeSpan constructorDuration = System.DateTime.Now.Subtract(constructorStartTime);
            System.Console.WriteLine(String.Format("ClassLibrary.Settings.SettingsConstructor Time Elapsed: {0}", constructorDuration.ToString()));
        }
Esempio n. 3
0
 public void Initialize()
 {
     //New instance of Settings
     _settings = new Settings();
 }
Esempio n. 4
0
 /// <summary>
 /// Indexes this instance.
 /// </summary>
 /// <returns>a view of Index page</returns>
 public object Index()
 {
     var settings = new Settings();
     return View(settings);
 }
 public object Show(string Id)
 {
     ViewData["id"] = Id;
     int prefId;
     try {
         prefId = Convert.ToInt32(Id);
     } catch (Exception) //not an integer
     {
         return RedirectToAction("Index", "Professor");
     }
     var ProfPrefs = (new PreferencesProvider().GetAllPreferencesByProfId(prefId));
     var settings = new Settings();
     if (ProfPrefs != null) {
         ViewData["NoMore"] = ProfPrefs.Count == settings.NumberOfPreferencesPerProfessor;
     }
     Professor professor = (new ProfessorProvider()).GetProfessorByID(prefId);
     if (professor != null) {
         ViewData["Message"] = "Create - Delete Preferences for [" + professor.FullName + "]";
     } else {
         return RedirectToAction("Index", "Professor");
     }
     return View(ProfPrefs);
 }