public void create(BannerAndLink model) { if (model.uploadFile != null && model.uploadFile.ContentLength > 0) { model.storeFile(); model.dbFile.createDate = DateTime.Now; db.dbFile.Add(model.dbFile); db.SaveChanges(); model.dbFileSqno = model.dbFile.sqno; } model.createDate = DateTime.Now; db.bannerAndLink.Add(model); db.SaveChanges(); }
public void create(BrochureAndAnnouncement model) { if (model.uploadFile != null && model.uploadFile.ContentLength > 0) { model.storeFile(); model.dbFile.createDate = DateTime.Now; db.dbFile.Add(model.dbFile); db.SaveChanges(); model.dbFileSqno = model.dbFile.sqno; } model.createDate = DateTime.Now; db.brochureAndAnnouncement.Add(model); db.SaveChanges(); }
public ActionResult CreateTeacher(CourseTeacher teacher) { if (ModelState.IsValid) { db.CourseTeacher.Add(teacher); 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 Create(Activity model) { if (ModelState.IsValid) { model.CreateDate = DateTime.Now; db.activity.Add(model); 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)); } }