public ActionResult code_nationality(code_nationality doc, string idx) { if (!string.IsNullOrEmpty(idx)) { doc = db.code_nationality.Single(x => x.code_id == idx); } return(View(doc)); }
public ActionResult code_nationality_action(code_nationality doc, string mode_type, string idx) { string msg = ""; if (string.IsNullOrEmpty(idx)) { #region 저장 doc.write_date = DateTime.Now; doc.writer_id = User.Identity.Name; doc.index_order = 9; doc.use_yn = "Y"; db.code_nationality.Add(doc); db.SaveChanges(); // 실제로 저장 msg = Util.msg.msg_insert; #endregion } else { if (mode_type == "D") { #region 삭제 code_nationality doc_del = db.code_nationality.Single(x => x.code_id == idx); db.code_nationality.Remove(doc_del); db.SaveChanges(); msg = Util.msg.msg_del; #endregion } else { #region 수정 doc.writer_id = User.Identity.Name; doc.write_date = DateTime.Now; doc.index_order = 9; doc.use_yn = "Y"; db.Entry(doc).State = EntityState.Modified; db.SaveChanges(); msg = Util.msg.msg_edit; #endregion } } return(Redirect("/code/code_nationality_list")); }