Beispiel #1
0
        /// <summary>
        /// 獲取課程data
        /// </summary>
        /// <returns></returns>
        public ActionResult GetCurricul(Course c)
        {
            try
            {
                int count = 0;
                c.Start = int.Parse(Request.Form["start"] ?? "0");
                if (Request["limit"] != null)
                {
                    c.Limit = Convert.ToInt32(Request["limit"]);
                }
                ICourseImplMgr _courseMgr = new CourseMgr(connectionString);
                bool isPage = Convert.ToBoolean(Request["IsPage"]);

                if (isPage)
                {
                    var course = _courseMgr.Query(c, out count);
                    IsoDateTimeConverter iso = new IsoDateTimeConverter() { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
                    return Content("{succes:true,totalCount:" + count + ",item:" + JsonConvert.SerializeObject(course, Formatting.None, iso) + "}");
                }
                else
                {
                    var course = _courseMgr.Query(c);
                    return Json(course);
                }

            }
            catch (Exception ex)
            {
                Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
                logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
                logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
                log.Error(logMessage);
                return new EmptyResult();
            }

        }
Beispiel #2
0
 /// <summary>
 /// 保存課程數據
 /// </summary>
 /// <param name="fst"></param>
 /// <returns></returns>
 public ActionResult CurriculSave(string courseStr, string courseDetailStrs, string imgStore)
 {
     try
     {
         Course course = JsonConvert.DeserializeObject<Course>(courseStr);
         List<CourseDetail> courseDetails = JsonConvert.DeserializeObject<List<CourseDetail>>(courseDetailStrs);
         List<CoursePicture> imgList = JsonConvert.DeserializeObject<List<CoursePicture>>(imgStore);
         imgServerPath = imgServerPath + "/course/a/";
         foreach(CoursePicture item in imgList)
         {
             item.picture_name = item.picture_name.Replace(imgServerPath, " ");
         }
         ICourseImplMgr _courseMgr = new CourseMgr(connectionString);
         return Json(new { success = _courseMgr.ExecuteAll(course, courseDetails, imgList) });
     }
     catch (Exception ex)
     {
         Log4NetCustom.LogMessage logMessage = new Log4NetCustom.LogMessage();
         logMessage.Content = string.Format("TargetSite:{0},Source:{1},Message:{2}", ex.TargetSite.Name, ex.Source, ex.Message);
         logMessage.MethodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
         log.Error(logMessage);
         return Json(new { success = false });
     }
 }