/// <summary> /// 消费积分 /// </summary> /// <param name="model"></param> /// <returns></returns> public ActionResult ConsumIntegralReclrd(IntegralRecord model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { var totalNumber = db.IntegralRecord.Where(p => p.ChildrenID == model.ChildrenID).OrderByDescending(p => p.ID).FirstOrDefault()?.TotalNumber ?? 0; model.CreateTime = DateTime.Now.ToString(FormatDateTime.ShortDateTimeStr); if (model.Number > totalNumber) { msg.Status = false; msg.Result = "800"; msg.Msg = "兑换积分超过剩余积分"; return(Json(msg, JsonRequestBehavior.AllowGet)); } model.TotalNumber = totalNumber - model.Number; var entity = db.IntegralRecord.Add(model); db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(PublicBox model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { bool isExisted = db.PublicBox.Any(p => p.ID != model.ID && p.LoginName == model.LoginName); if (isExisted) { msg.Status = false; msg.Result = "700"; return(Json(msg, JsonRequestBehavior.AllowGet)); } db.PublicBox.Attach(model); db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 未使用,时间是在DefaultCourseSetting/SetModel 里先删除后添加的 /// </summary> /// <param name="childrenID"></param> /// <returns></returns> public ActionResult Update(int childrenID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { using (var scope = db.Database.BeginTransaction()) { ResponseMessage msg = new ResponseMessage(); try { int courseClassType = int.Parse(Request.Form["courseClassType"]); db.Database.ExecuteSqlCommand("delete DefaultCourseTimeSetting where ChildrenID= " + childrenID); var modelList = Request.Form["modelList"]; var list = JsonConvert.DeserializeObject <List <DefaultCourseTimeSetting> >(modelList); var entity = db.DefaultCourseTimeSetting.AddRange(list); db.SaveChanges(); msg.Status = true; scope.Commit(); } catch (Exception e) { msg.Status = false; scope.Rollback(); } return(Json(msg, JsonRequestBehavior.AllowGet)); } } }
//IntegralRecord public ActionResult Index(int childrenID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var tempList = db.IntegralRecord.Where(p => p.ChildrenID == childrenID).OrderByDescending(p => p.ID).ToList(); var totalNumber = tempList.FirstOrDefault()?.TotalNumber ?? 0; List <IntegralRecordBusiness> list = new List <IntegralRecordBusiness>(); foreach (var item in tempList) { var bitem = ObjectHelper.TransReflection <IntegralRecord, IntegralRecordBusiness>(item); string calcStr = "获得"; string prefix = "完成"; if (item.CalcType == (int)EnumUnit.IntegralRecordCalcTypeEnum.Reduce) { calcStr = "减少"; prefix = "取消"; } if (item.CalcType == (int)EnumUnit.IntegralRecordCalcTypeEnum.Consum) { calcStr = "减少"; prefix = "兑换"; } bitem.ShowName = bitem.CreateTime + prefix + bitem.Name + calcStr + bitem.Number + "个积分"; list.Add(bitem); } msg.Data = new { list, totalNumber }; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(PublicCourseInfo model) { LogHelper.Info("PublicCourseInfoController->Update"); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { //bool isExisted = db.PublicCourseInfo.Any(p => p.ID != model.ID && p.LoginName == model.LoginName); //if (isExisted) //{ // msg.Status = false; // msg.Result = "700"; // return Json(msg, JsonRequestBehavior.AllowGet); //} db.PublicCourseInfo.Attach(model); db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(Children model) { LogHelper.Info("ChildrenController->Add"); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); using (var scope = db.Database.BeginTransaction()) { try { var entity = db.Children.Add(model); db.SaveChanges(); //初始化课程 var defaultCourseList = db.DefaultCourse.Where(p => p.AppClass == ApplicationConstant.Course).OrderBy(p => p.Sort).ToList(); db.ChildrenStandardCourse.AddRange(defaultCourseList.Select(x => new ChildrenStandardCourse() { ChildrenID = entity.ID, CourseName = x.CourseName, Sort = x.Sort })); db.SaveChanges(); //初始化打卡 var clockProjectList = db.DefaultCourse.Where(p => p.AppClass == ApplicationConstant.Clock).OrderBy(p => p.Sort).ToList(); db.ClockProject.AddRange(clockProjectList.Select(x => new ClockProject() { ChildrenID = entity.ID, Name = x.CourseName, Sort = x.Sort, Type = x.Type })); db.SaveChanges(); //初始化积分兑换项目 var exchangeProjectList = db.DefaultCourse.Where(p => p.AppClass == ApplicationConstant.Exchange).OrderBy(p => p.Sort).ToList(); db.ExchangeProject.AddRange(exchangeProjectList.Select(x => new ExchangeProject() { ChildrenID = entity.ID, Name = x.CourseName, Sort = x.Sort, Value = x.Value })); db.SaveChanges(); scope.Commit(); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; scope.Rollback(); } return(Json(msg, JsonRequestBehavior.AllowGet)); } } }
public ActionResult IndexByPublicCourseInfoID(int publicCourseInfoID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.DefaultCourseTimeSetting.Where(p => p.PublicCourseInfoID == publicCourseInfoID).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index(string openID, int publicBoxType) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.PublicBox.Where(p => p.OpenID == openID && p.PublicBoxType == publicBoxType).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/*********************************************************************************************** * 弃用 ,统一使用 Course 表 ************************************************************************************************/ // GET: PublicPublicCourse public ActionResult Index(int publicCourseTypeID, string openID, int page = 1, int pageSize = 7) { ResponseMessage msg = new ResponseMessage(); List <PublicCourseBusiness> cbList = new List <PublicCourseBusiness>(); string startTime; string endTime; DateTime st; DateTime et; Children cModel = new Children(); var ct = DateCalc.GetWeekFirstDayMon(DateTime.Now); st = ct.AddDays((page - 1) * pageSize); et = ct.AddDays(page * pageSize); startTime = st.ToString(FormatDateTime.ShortDateTimeStr); endTime = et.ToString(FormatDateTime.ShortDateTimeStr); List <PublicCourse> cList = new List <PublicCourse>(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { msg.Status = true; try { cList = db.PublicCourse.Where(p => p.PublicCourseTypeID == publicCourseTypeID && string.Compare(p.StartTime, startTime, StringComparison.Ordinal) >= 0 && string.Compare(p.EndTime, endTime, StringComparison.Ordinal) <= 0) .ToList(); //默认使用第一个孩子的背景色 cModel = db.Children.FirstOrDefault(p => p.OpenID == openID); //防止没有孩子的情况出现。 if (cModel == null) { cModel = new Children(); } } catch (Exception e) { msg.Status = false; } } for (int i = 0; i < pageSize; i++) { PublicCourseBusiness model = new PublicCourseBusiness(); model.DayOfWeek = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(st.AddDays(i).DayOfWeek); model.StartTime = st.AddDays(i).ToString(FormatDateTime.ShortDateTimeStr); model.BackgroundColor = cList.Any(p => p.StartTime.Contains(model.StartTime)) ? cModel.Background : ""; model.IsToday = model.StartTime == DateTime.Now.ToString(FormatDateTime.ShortDateTimeStr) ? true : false; cbList.Add(model); } msg.Data = cbList; return(Json(msg, JsonRequestBehavior.AllowGet)); }
//ExchangeProject public ActionResult Index(int childrenID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.ExchangeProject.Where(p => p.ChildrenID == childrenID).OrderBy(p => p.ID).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult IsFirstOpenPage(string openID, string page) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var ok = db.PageCommon.Any(p => p.OpenID == openID && p.Page == page); msg.Data = !ok; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult IndexByPublicCourseInfoID(int publicCourseInfoID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.ChildrenStandardCourse.Where(p => p.PublicCourseInfoID == publicCourseInfoID).OrderBy(p => p.Sort).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetDefaultCourseSettingByPublicCourseInfoID(int publicCourseInfoID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var model = db.DefaultCourseSetting.Where(p => p.PublicCourseInfoID == publicCourseInfoID).FirstOrDefault(); msg.Data = model; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
//MemorandumGroupGroup public ActionResult Index(string openID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.MemorandumGroup.Where(p => p.OpenID == openID).OrderBy(p => p.ID).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 根据外出清单ID获取备忘列表 /// </summary> /// <param name="groupID"></param> /// <returns></returns> public ActionResult GetListByGroupID(int groupID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; var list = db.Memorandum.Where(p => p.GroupID == groupID && p.Type == (int)EnumUnit.MemorandumTypeEnum.GroupMemorandum).OrderBy(p => p.StartTime).ToList(); msg.Data = list; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetMemorandumGroupByID(int id) { ResponseMessage msg = new ResponseMessage(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { var model = db.MemorandumGroup.FirstOrDefault(p => p.ID == id); msg.Status = true; msg.Data = model; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 获取打卡列表和番茄钟列表的公共方法 /// </summary> /// <param name="childrenID"></param> /// <param name="isTomato"></param> /// <returns></returns> private ResponseMessage GetClockAndTomatoList(int childrenID, bool isTomato) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; DateTime now = DateTime.Now; var today = now.ToString(FormatDateTime.ShortDateTimeStr); //今日是周几 int weekIndex = (int)now.DayOfWeek; if (weekIndex == 0) { weekIndex = 7; } //本周开始时间 string weekStartStr = now.AddDays(-weekIndex).ToString(FormatDateTime.ShortDateTimeStr); //本周结束时间 string weekEndStr = now.AddDays(-weekIndex).AddDays(7).ToString(FormatDateTime.ShortDateTimeStr) + ApplicationConstant.EndTimeSuffix; //本月开始时间 string mouthStartStr = new DateTime(now.Year, now.Month, 1).ToString(FormatDateTime.ShortDateTimeStr); //本月结束时间 string mouthEndStr = new DateTime(now.Year, now.Month, 1).AddMonths(1).AddDays(-1) .ToString(FormatDateTime.ShortDateTimeStr) + ApplicationConstant.EndTimeSuffix; var query = db.Clock.Where(p => p.ChildrenID == childrenID); if (isTomato) { query = query.Where(p => p.IsLimit == true); } var list = query.OrderBy(p => p.ID).ToList(); msg.Data = new { //今日打卡任务 todayClockList = list.Where(p => p.Frequency == ((int)EnumUnit.ClockFrequencyEnum.Fixed).ToString() && p.ClockDate == today).ToList(), //本周打卡任务 weekList = list.Where(p => p.Frequency == ((int)EnumUnit.ClockFrequencyEnum.EveryWeek).ToString() && string.Compare(p.ClockDate, weekStartStr, StringComparison.Ordinal) >= 0 && string.Compare(p.ClockDate, weekEndStr, StringComparison.Ordinal) <= 0).ToList(), //本月打卡任务 mouthClockList = list.Where(p => p.Frequency == ((int)EnumUnit.ClockFrequencyEnum.EveryMouth).ToString() && string.Compare(p.ClockDate, mouthStartStr, StringComparison.Ordinal) >= 0 && string.Compare(p.ClockDate, mouthEndStr, StringComparison.Ordinal) <= 0).ToList(), //历史打卡任务 historyClockList = list.Where(p => string.Compare(p.ClockDate, today, StringComparison.Ordinal) <= 0).ToList(), //今日自定义打卡任务 todayAddList = list.Where(p => p.Frequency == ((int)EnumUnit.ClockFrequencyEnum.TodayAdd).ToString() && p.ClockDate == today).ToList(), }; return(msg); } }
public ActionResult GetMemorandumByID(int id) { LogHelper.Info("MemorandumController->GetMemorandumByID"); ResponseMessage msg = new ResponseMessage(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { var model = db.Memorandum.FirstOrDefault(p => p.ID == id); msg.Status = true; msg.Data = model; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Index(string openID, int publicBoxID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); msg.Status = true; //var list = db.PublicCourseInfo.Where(p => p.OpenID == openID && p.PublicBoxID == publicBoxID).ToList(); var list = db.PublicCourseInfo.Where(p => p.PublicBoxID == publicBoxID).ToList(); var diary = list.Where(p => p.DefaultType == (int)EnumUnit.PublicCourseInfoDefaultEnum.Diary).ToList(); var familyCurriculum = list.Where(p => p.DefaultType == (int)EnumUnit.PublicCourseInfoDefaultEnum.FamilyCurriculum).ToList(); msg.Data = new { diary, familyCurriculum }; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetChildrenPublicCourseByDate(int publicCourseTypeID, string startTime, string endTime) { ResponseMessage msg = new ResponseMessage(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { msg.Status = true; try { var list = db.PublicCourse.Where(p => p.PublicCourseTypeID == publicCourseTypeID && string.Compare(p.StartTime, startTime, StringComparison.Ordinal) >= 0 && string.Compare(p.EndTime, endTime, StringComparison.Ordinal) <= 0) .ToList(); List <PublicCourseBusiness> cbList = new List <PublicCourseBusiness>(); foreach (var item in list) { PublicCourseBusiness model = new PublicCourseBusiness(); model.Address = item.Address; model.PublicCourseTypeID = item.PublicCourseTypeID; model.CourseName = item.CourseName; model.EndTime = item.EndTime; model.ID = item.ID; if (string.IsNullOrWhiteSpace(item.RemindTime) || item.RemindTime == "-9999") { model.RemindDes = "未设置"; } else { model.RemindDes = DateTime.Parse(item.StartTime).AddMinutes(int.Parse(item.RemindTime)) < DateTime.Now ? "已提醒" : "未提醒"; } model.RemindTime = item.RemindTime; model.Phone = item.Phone; model.Remarks = item.Remarks; model.SchoolName = item.SchoolName; model.StartTime = item.StartTime; model.Teacher = item.Teacher; cbList.Add(model); } msg.Data = cbList; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } } return(Json(msg, JsonRequestBehavior.AllowGet)); }
public ActionResult SetModel() { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { //添加默认时间 var modelStr = Request.Form["model"]; int courseClassType = int.Parse(Request.Form["courseClassType"]); var model = JsonConvert.DeserializeObject <DefaultCourseSetting>(modelStr); //代表添加 if (model.ID == 0) { var entity = db.DefaultCourseSetting.Add(model); } else//代表编辑 { db.DefaultCourseSetting.Attach(model); db.Entry(model).State = System.Data.Entity.EntityState.Modified; } //删除默认时间设置 if (courseClassType == (int)EnumUnit.CourseClassEnum.PrivateCourse) { db.Database.ExecuteSqlCommand("delete DefaultCourseTimeSetting where ChildrenID= " + model.ChildrenID); } else { db.Database.ExecuteSqlCommand("delete DefaultCourseTimeSetting where PublicCourseInfoID= " + model.PublicCourseInfoID); } //添加默认时间 var timeModelList = Request.Form["timeModelList"]; var list = JsonConvert.DeserializeObject <List <DefaultCourseTimeSetting> >(timeModelList); db.DefaultCourseTimeSetting.AddRange(list); db.SaveChanges(); //上面的时间加上之后再修改下面的时间 //更改课程时间 不管是默认设置,还是“新增课程(日程)”里面的手动设置,时间设置上都应该是以最后修改的那个时间为准。 string sql = UpdateCourseTime(model.ChildrenID, model.PublicCourseInfoID, courseClassType); db.Database.ExecuteSqlCommand(sql); msg.Status = true; } catch (Exception e) { msg.Status = false; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.Database.ExecuteSqlCommand("delete DefaultCourseSetting where id= " + id); msg.Status = true; } catch (Exception e) { msg.Status = false; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(ChildrenStandardCourse model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { var entity = db.ChildrenStandardCourse.Add(model); db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult DeleteByClockID(int clockID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.Database.ExecuteSqlCommand("delete IntegralRecord where ClockID= " + clockID); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Update(ChildrenStandardCourse model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.ChildrenStandardCourse.Attach(model); db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 结束习惯 /// </summary> /// <param name="batchID"></param> /// <returns></returns> public ActionResult Delete(string batchID) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { string startTime = DateTime.Now.ToString(FormatDateTime.ShortDateTimeStr); db.Database.ExecuteSqlCommand("delete Clock where BatchID= '" + batchID + "' and ClockDate>='" + startTime + "'"); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult GetPublicCourseInfoByLoginNameAndPassword(string loginName, string password) { ResponseMessage msg = new ResponseMessage(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { var model = db.PublicCourseInfo.FirstOrDefault(p => p.LoginName == loginName && p.Password == password); if (model != null) { msg.Status = true; } else { msg.Status = false; } msg.Data = model; return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Add(MemorandumGroup model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { var entity = db.MemorandumGroup.Add(model); db.SaveChanges(); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// 重置 /// </summary> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public ActionResult Deletes(int publicCourseInfoID, string startTime, string endTime) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.Database.ExecuteSqlCommand("delete PublicCourse where PublicCourseInfoID=" + publicCourseInfoID + " and StartTime>= '" + startTime + "' and EndTime<='" + endTime + "'"); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }
public ActionResult Delete(int id) { LogHelper.Info("ChildrenController->Delete"); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.Database.ExecuteSqlCommand("delete Children where id= " + id); msg.Status = true; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }