Esempio n. 1
0
 /// <summary>
 /// 用户添加学习心得
 /// </summary>
 /// <param name="userid"></param>
 public ActionResult AddLearnGain(int userid, int resultID)
 {
     CourseResult result = (from r in CQGJ.CourseResult
                            where r.ResultID == resultID
                            select r).First();
     LearnGain learn = new LearnGain();
     if (GetString("title") != "")
     {
         learn.CourseResult = result;
         learn.Title = GetString("title");
         learn.Content = GetString("Content");
         learn.PubTime = GetDate("PubTime");
         CQGJ.AddToLearnGain(learn);
         CQGJ.SaveChanges();
     }
     return View("AddLearnGain");
 }
Esempio n. 2
0
        /// <summary>
        /// 心得体会保存 - 创建时
        /// </summary>
        public ActionResult LearnCreate()
        {
            UserPLViewData viewData = new UserPLViewData();
            viewData.user = GetUser();
            int userID = viewData.user.UserID;
            int id = GetInt("lCourse");

            var courseResultTemp = (from cr in CQGJ.CourseResult
                                    where cr.Course.CourseID == id && cr.Student.User.UserID == userID
                                    select cr);
            bool flag = false;
            viewData.course = (from c in CQGJ.Course
                               where c.CourseID == id
                               select c).First();
            CourseResult crTmp = new CourseResult();
            try
            {
                crTmp = courseResultTemp.First();
            }
            catch
            {
                flag = true;
            }
            if (flag)
            {
                crTmp.Course = viewData.course;
                crTmp.Student = (from s in CQGJ.Student
                                 where s.User.UserID == userID
                                 select s).First();
                CQGJ.AddToCourseResult(crTmp);
                CQGJ.SaveChanges(true);
            }

            LearnGain learn = new LearnGain();
            learn.CourseResult = crTmp;
            learn.Content = GetString("Content");
            learn.Title = GetString("lTitle");
            learn.PubTime = DateTime.Now;
            CQGJ.AddToLearnGain(learn);
            CQGJ.SaveChanges(true);
            return RedirectToAction("mylearn", "user");
        }