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 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)); } }
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 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)); } }
public ActionResult Update(GrowthDiary model) { using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { model.UpdateTime = DateTime.Now.ToString(FormatDateTime.LongDateTimeStr); db.GrowthDiary.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)); } }
public ActionResult Update(Children model) { LogHelper.Info("ChildrenController->Update"); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { ResponseMessage msg = new ResponseMessage(); try { db.Children.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> /// 打卡 /// </summary> /// <returns></returns> public ActionResult ExecuteClock(int id, EnumUnit.ClockExecuteTypeEnum executeType) { ResponseMessage msg = new ResponseMessage(); using (ClassScheduleDBEntities db = new ClassScheduleDBEntities()) { try { var model = db.Clock.FirstOrDefault(p => p.ID == id); //打卡 if (executeType == EnumUnit.ClockExecuteTypeEnum.Punch) { //已经完成打卡 if (model.ExecutedNum >= model.ExecuteNum) { msg.Status = false; msg.Result = "800"; return(Json(msg, JsonRequestBehavior.AllowGet)); } model.ExecutedNum++; }//取消打卡 else if (executeType == EnumUnit.ClockExecuteTypeEnum.Cancel) { //已取消完所有打卡 if (model.ExecutedNum == 0) { msg.Status = false; msg.Result = "801"; return(Json(msg, JsonRequestBehavior.AllowGet)); } //减少积分 if (model.ExecutedNum == model.ExecuteNum && model.RewardPoints > 0) { AddIntegralRecord(model, EnumUnit.IntegralRecordCalcTypeEnum.Reduce); } model.ExecutedNum--; model.IsComplated = false; } //校验是否完成本周期打卡任务 if (model.ExecutedNum == model.ExecuteNum) { model.IsComplated = true; //增加积分 if (model.RewardPoints > 0) { AddIntegralRecord(model, EnumUnit.IntegralRecordCalcTypeEnum.Plus); } } db.Entry(model).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); msg.Status = true; msg.Data = model; } catch (Exception e) { msg.Status = false; msg.Result = "500"; } return(Json(msg, JsonRequestBehavior.AllowGet)); } }