public ActionResult EditCourseGroup(CourseGroup model) { if (ModelState.IsValid) { db.Entry(model).State = EntityState.Modified; db.SaveChanges(); var result = new { success = true }; return(Json(result)); } else { var result = new { success = false, errorMessage = "資料有誤,請檢查並更正資料", ModelStateErrors = ModelState.Where(x => x.Value.Errors.Count > 0) .ToDictionary(k => k.Key, k => k.Value.Errors.Select(e => e.ErrorMessage).ToArray()) }; return(Json(result)); } }
public void edit(BannerAndLink model) { if (model.uploadFile != null && model.uploadFile.ContentLength > 0) { model.dbFile = db.dbFile.Where(x => x.sqno == model.dbFileSqno).FirstOrDefault(); if (model.dbFile == null) { model.storeFile(); model.dbFile.createDate = DateTime.Now; db.dbFile.Add(model.dbFile); db.SaveChanges(); model.dbFileSqno = model.dbFile.sqno; } else { model.storeFile(); db.Entry(model.dbFile).State = EntityState.Modified; db.SaveChanges(); } } db.Entry(model).State = EntityState.Modified; db.SaveChanges(); }
public ActionResult EditTeacherPopup(CourseTeacher teacher) { if (ModelState.IsValid) { teacher.courses = db.CourseTeacher.Where(t => t.sqno == teacher.sqno).SelectMany(t => t.courses).ToList(); db.Entry(teacher).State = EntityState.Modified; db.SaveChanges(); var result = new { success = true }; return(Json(result)); } else { var result = new { success = false, errorMessage = "資料有誤,請檢查並更正資料", ModelStateErrors = ModelState.Where(x => x.Value.Errors.Count > 0) .ToDictionary(k => k.Key, k => k.Value.Errors.Select(e => e.ErrorMessage).ToArray()) }; return(Json(result)); } }
public ActionResult QualificationVerify(MemberQualificationVerifyViewModel model) { try { model.member = db.Member.Where(m => m.sqno == model.sqno && m.MemberGroupResult.Count() == 0).FirstOrDefault(); if (model.member == null) { ViewBag.ErrorMessage = "找不到資料"; return(Index()); } if (ModelState.IsValid) { MemberGroupResult newResult = new MemberGroupResult(model.member); if (model.isPass) { newResult.AppraiseStep = 1; newResult.AppraiseGroup = model.group; newResult.AppraiseState = "通過資格審"; newResult.AppraiseDesc = model.desc; } else { newResult.AppraiseStep = 7; newResult.AppraiseState = "資格審未錄取"; newResult.AppraiseDesc = model.desc; } db.Entry(model.member).State = EntityState.Modified; db.SaveChanges(); return(View("Close")); } ViewBag.groupList = DropDownListHelper.getAppraiseGroupNameList(false); return(View(model)); } catch (Exception e) { return(QualificationVerify(model.sqno)); } }