Esempio n. 1
0
 public TearcherAddCourseInModel AddCourse(string name, string type, string isOpen, string isOffline, string time, string imgName, StudentClient.Models.Teacher tearcher)
 {
     try
     {
         StudentClient.Models.Cours course = new Models.Cours();
         course.Course_Id        = Guid.NewGuid();
         course.Course_IsDel     = false;
         course.Course_IsOffline = bool.Parse(isOffline);
         course.Course_IsOpen    = bool.Parse(isOpen);
         course.Course_Major     = type;
         course.Course_Name      = name;
         course.Course_Password  = "******";
         course.Course_College   = tearcher.School.School_Name;
         course.Course_IsGeneral = false;
         course.Course_Week      = time.Split(' ')[0];
         course.Course_DayOfWeek = time.Split(' ')[1];
         course.Course_Time      = new TimeSpan(1, 1, 1);
         course.Course_Teacher   = tearcher.Teacher_Id;
         base.Add(course);
         File.Move(imgName, Path.Combine(Path.GetDirectoryName(imgName), String.Format("{0}.png", course.Course_Id)));
         TearcherAddCourseInModel addCourse = new TearcherAddCourseInModel();
         addCourse.IsAdd = true;
         addCourse.Id    = course.Course_Id.ToString();
         return(addCourse);
     }
     catch (Exception e)
     {
         mLog.Error("An error has occurred in the add course,error:{0}", e.ToString());
         throw;
     }
 }
Esempio n. 2
0
        private static void AddCourseToDb(CourseCreator courseData)
        {
            #region WRITE COURSE DATA TO DB

            using (var db = new NotifyLocalDBEntities())
            {
                var newCourse = new Models.Cours()
                {
                    courseName     = courseData.Name,
                    portalCourseId = courseData.Id,
                    userId         = Properties.Settings.Default.UserId
                };

                db.Courses.Add(newCourse);
                db.SaveChanges();
            }

            #endregion WRITE COURSE DATA TO DB
        }