Esempio n. 1
0
 static public Persistence.Cours dict2Course(Dictionary <string, string> course)
 {
     try
     {
         Persistence.Cours courseData = new Persistence.Cours();
         courseData.Course_Name     = course["Name"];
         courseData.Syllabus_Course = course["Syllabus"];
         courseData.Active_Course   = Convert.ToBoolean(course["Active"]);
         courseData.Category_Course = course["Category"];
         courseData.Passing_Score   = Int32.Parse(course["Passing_Score"]);
         return(courseData);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message.ToString());
         return(null);
     }
 }
Esempio n. 2
0
        //public override Persistence.User FetchUser(int nationalID, int RoleID)
        //{
        //    CRUD.User user = new CRUD.User();
        //    return (Persistence.User) user.FetchUserData(nationalID, RoleID);

        //}

        /// <summary>
        /// Creates a new course in the data base. Returns false on error or incorrect dictionary keys.
        /// </summary>
        /// <param name="course">Type Dictionary<string,string></param>
        /// <returns></returns>
        public override bool CreateCourse(Dictionary <string, string> course)
        {
            try
            {
                Persistence.Cours courseData = Util.dict2Course(course);
                if (courseData != null)
                {
                    Course CRUDcourse = new Course();
                    CRUDcourse.CreateCourse(courseData);
                    return(true);
                }
                else
                {
                    throw new ArgumentException("One or more of the required keys were not found.");
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message.ToString());
                return(false);
            }
        }