public ActionResult Delete(FormCollection collection) { /* * 变量定义 */ // 申请ID int aid = 0; /* * 参数获取 */ // 申请id var id = collection["id"]; /* * 参数校验 */ // 申请ID if (string.IsNullOrEmpty(id)) { return(ResponseUtil.Error(400, "申请ID不能为空")); } else { if (!int.TryParse(id, out aid)) { return(ResponseUtil.Error(400, "申请ID不正确")); } } /* * 删除申请 */ using (var db = new YGSDbContext()) { var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault(); if (apply == null) { return(ResponseUtil.Error(400, "申请不存在")); } else { // 查询所有对应的履历 // 获得所有外出人员id //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList(); //var historyList = db.History.Where(n => historyIdList.Contains(n.ID)).ToList(); //db.History.RemoveRange(historyList); //db.Apply.Remove(apply); apply.IsDelete = true; db.SaveChanges(); return(ResponseUtil.OK(200, "删除成功")); } } }
public ActionResult Delete(FormCollection collection) { /* * 变量定义 */ // 用户ID int id = 0; /* * 参数获取 */ // 用户ID var userId = collection["id"]; /* * 参数校验 */ // 用户ID if (string.IsNullOrEmpty(userId)) { return(ResponseUtil.Error(400, "用户ID不能为空")); } else { if (!int.TryParse(userId, out id)) { return(ResponseUtil.Error(400, "用户ID不正确")); } } /* * 用户查询 */ using (var db = new YGSDbContext()) { var user = db.User.Where(n => n.ID == id).FirstOrDefault(); if (user == null) { return(ResponseUtil.Error(400, "用户不存在")); } else { // 检查该用户是否有护照信息,也要一并删除 var credList = db.Cred.Where(n => n.UserID == id).ToList(); db.Cred.RemoveRange(credList); db.User.Remove(user); db.SaveChanges(); return(ResponseUtil.OK(200, "用户删除成功")); } } }
public ActionResult Delete(int id) { /* * 证件查询 */ using (var db = new YGSDbContext()) { var cred = db.Cred.Where(n => n.ID == id).FirstOrDefault(); if (cred == null) { return(ResponseUtil.Error(400, "证件不存在")); } else { db.Cred.Remove(cred); db.SaveChanges(); return(ResponseUtil.OK(200, "删除成功")); } } }
public ActionResult Delete(int id) { /* * 查询履历 */ using (var db = new YGSDbContext()) { var history = db.History.Where(n => n.ID == id).FirstOrDefault(); if (history == null) { return(ResponseUtil.Error(400, "履历不存在")); } else { db.History.Remove(history); db.SaveChanges(); return(ResponseUtil.OK(200, "删除成功")); } } }
public ActionResult Delete(int id) { using (var db = new YGSDbContext()) { var apply = db.Apply.Where(n => n.ID == id).FirstOrDefault(); if (apply == null) { return(ResponseUtil.Error(400, "申请不存在")); } else { // 查询所有对应的履历 // 获得所有外出人员id //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList(); //var historyList = db.History.Where(n => historyIdList.Contains(n.ID)).ToList(); //db.History.RemoveRange(historyList); //db.Apply.Remove(apply); apply.IsDelete = true; db.SaveChanges(); return(ResponseUtil.OK(200, "删除成功")); } } }
public ActionResult DoUpdate(FormCollection collection) { /* * 变量定义 */ // 证件ID int tradeId = 0; // 发照日期 DateTime credDate = new DateTime(); // 有效期 DateTime validDate = new DateTime(); /* * 参数获取 */ // 证件ID var tradeIdString = collection["tradeId"]; // 证件号 var tradeCode = collection["tradeCode"]; // 证件类型 var credType = collection["credType"]; // 发照机关 var credUnit = collection["credUnit"]; // 发照日期 var credDateString = collection["credDate"]; // 有效期 var validDateString = collection["validDate"]; // 有效状态 var validStatus = collection["validStatus"]; /* * 参数校验 */ // 证件ID if (string.IsNullOrEmpty(tradeIdString)) { return(ResponseUtil.Error(400, "证件ID不能为空")); } else { if (!int.TryParse(tradeIdString, out tradeId)) { return(ResponseUtil.Error(400, "证件ID不正确")); } } // 证件号 if (string.IsNullOrEmpty(tradeCode)) { return(ResponseUtil.Error(400, "证件号不能为空")); } // 证件类型 //if (string.IsNullOrEmpty(credType)) //{ // return ResponseUtil.Error(400, "证件类型不能为空"); //} // 发照机关 //if (string.IsNullOrEmpty(credUnit)) //{ // return ResponseUtil.Error(400, "发照机关不能为空"); //} // 发照日期 if (!string.IsNullOrEmpty(credDateString)) { if (!DateTime.TryParse(credDateString, out credDate)) { return(ResponseUtil.Error(400, "发照日期格式不正确")); } } // 有效期 if (!string.IsNullOrEmpty(validDateString)) { if (!DateTime.TryParse(validDateString, out validDate)) { return(ResponseUtil.Error(400, "有效期格式不正确")); } } // 有效状态 //if (string.IsNullOrEmpty(validStatus)) //{ // return ResponseUtil.Error(400, "有效状态不能为空"); //} /* * 证件查询 */ using (var db = new YGSDbContext()) { var cred = db.Cred.Where(n => n.ID == tradeId).FirstOrDefault(); if (cred == null) { return(ResponseUtil.Error(400, "证件不存在")); } else { var existsCred = db.Cred.Where(n => n.TradeCode == tradeCode).FirstOrDefault(); if (existsCred != null && existsCred.ID != cred.ID) { return(ResponseUtil.Error(400, "相同证件号已存在")); } else { cred.TradeCode = tradeCode; cred.CredType = credType; cred.CredUnit = credUnit; if (string.IsNullOrEmpty(credDateString)) { cred.CredDate = null; } else { cred.CredDate = credDate; } if (string.IsNullOrEmpty(validDateString)) { cred.ValidDate = null; } else { cred.ValidDate = validDate; } cred.ValidStatus = validStatus; db.SaveChanges(); return(ResponseUtil.OK(200, "更新成功")); } } } }
public ActionResult DoAdd(FormCollection collection) { /* * 变量定义 */ // 用户ID int uid = 0; // 发照日期 DateTime credDate = new DateTime(); // 有效期 DateTime validDate = new DateTime(); /* * 参数获取 */ // 用户ID var userId = collection["userId"]; // 证件号 var tradeCode = collection["tradeCode"]; // 证件类型 var credType = collection["credType"]; // 发照机关 var credUnit = collection["credUnit"]; // 发照日期 var credDateString = collection["credDate"]; // 有效期 var validDateString = collection["validDate"]; // 有效状态 var validStatus = collection["validStatus"]; /* * 参数校验 */ // 用户ID if (string.IsNullOrEmpty(userId)) { return(ResponseUtil.Error(400, "用户ID不能为空")); } else { if (!int.TryParse(userId, out uid)) { return(ResponseUtil.Error(400, "用户ID不正确")); } } // 证件号 if (string.IsNullOrEmpty(tradeCode)) { return(ResponseUtil.Error(400, "证件号不能为空")); } // 证件类型 //if (string.IsNullOrEmpty(credType)) //{ // return ResponseUtil.Error(400, "证件类型不能为空"); //} // 发照机关 //if (string.IsNullOrEmpty(credUnit)) //{ // return ResponseUtil.Error(400, "发照机关不能为空"); //} // 发照日期 if (!string.IsNullOrEmpty(credDateString)) { if (!DateTime.TryParse(credDateString, out credDate)) { return(ResponseUtil.Error(400, "发照日期格式不正确")); } } // 有效期 if (!string.IsNullOrEmpty(validDateString)) { if (!DateTime.TryParse(validDateString, out validDate)) { return(ResponseUtil.Error(400, "有效期格式不正确")); } } // 有效状态 //if (string.IsNullOrEmpty(validStatus)) //{ // return ResponseUtil.Error(400, "有效状态不能为空"); //} /* * 用户查询 */ using (var db = new YGSDbContext()) { var existsCred = db.Cred.Where(n => n.TradeCode == tradeCode).FirstOrDefault(); if (existsCred != null) { return(ResponseUtil.Error(400, "相同证件号已存在")); } else { var user = db.User.Where(n => n.ID == uid).FirstOrDefault(); if (user == null) { return(ResponseUtil.Error(400, "用户不存在")); } else { var cred = new YGS_Cred(); cred.UserID = uid; cred.Name = user.Name; cred.Sex = user.Sex; cred.TradeCode = tradeCode; cred.CredType = credType; cred.CredUnit = credUnit; if (string.IsNullOrEmpty(credDateString)) { cred.CredDate = null; } else { cred.CredDate = credDate; } if (string.IsNullOrEmpty(validDateString)) { cred.ValidDate = null; } else { cred.ValidDate = validDate; } cred.ValidStatus = validStatus; cred.CreateTime = DateTime.Now; cred.UpdateTime = DateTime.Now; db.Cred.Add(cred); db.SaveChanges(); return(ResponseUtil.OK(200, "添加成功")); } } } }
public ActionResult Check(FormCollection collection) { /* * 变量定义 */ // 申请ID int aid = 0; /* * 参数获取 */ // 申请ID var id = collection["id"]; // 审批意见 var checkOpinion = collection["checkOpinion"]; // 审批状态 var checkStatus = collection["checkStatus"]; /* * 参数校验 */ // 申请ID if (string.IsNullOrEmpty(id)) { return(ResponseUtil.Error(400, "申请ID不能为空")); } else { if (!int.TryParse(id, out aid)) { return(ResponseUtil.Error(400, "申请ID不正确")); } } // 审批意见 if (string.IsNullOrEmpty(checkOpinion)) { return(ResponseUtil.Error(400, "审批意见不能为空")); } // 审批状态 if (string.IsNullOrEmpty(checkStatus)) { return(ResponseUtil.Error(400, "审批状态不能为空")); } /* * 审核逻辑 */ using (var db = new YGSDbContext()) { var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault(); if (apply == null) { return(ResponseUtil.Error(400, "申请不存在")); } else { apply.CheckOpinion = checkOpinion; if (checkStatus == WHConstants.Check_Status_Pass) { // 获得所有外出人员id //var historyIdList = apply.OutUsers.Split(',').Select(int.Parse).ToList(); //var outUserIds = db.History.Where(n => historyIdList.Contains(n.ID)).Select(n => n.UserId).ToList(); //var illegalUsers = db.User.Where(m => outUserIds.Contains(m.ID) && string.IsNullOrEmpty(m.CredNo)).ToList(); //if (illegalUsers.Count > 0) //{ // return ResponseUtil.Error(400, "出国人员缺少身份证号,请先到申请详情中补全"); //} //else //{ // apply.ApplyStatus = WHConstants.Apply_Status_Passed; // NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/"); //} apply.ApplyStatus = WHConstants.Apply_Status_Passed; NotificationUtil.SendNotification(apply.UserId, "您的出国申请已通过", "/Apps/YGS/Home/"); } else { apply.ApplyStatus = WHConstants.Apply_Status_Rejected; NotificationUtil.SendNotification(apply.UserId, "您的出国申请被拒绝", "/Apps/YGS/Home/"); } db.SaveChanges(); return(ResponseUtil.OK(200, "审批成功")); } } }
public ActionResult DoUpdate(FormCollection collection) { /* * 变量定义 */ // 申请ID int aid = 0; // 出访日期 DateTime outDate = new DateTime(); /* * 参数获取 */ // 申请ID var id = collection["id"]; // 出访日期 var outDateString = collection["outDate"]; // 签证情况 var signStatus = collection["signStatus"]; // 履历ID列表 var outUsers = collection["outUsers"]; /* * 参数校验 */ // 申请ID if (string.IsNullOrEmpty(id)) { return(ResponseUtil.Error(400, "申请ID不能为空")); } else { if (!int.TryParse(id, out aid)) { return(ResponseUtil.Error(400, "申请ID不正确")); } } // 出访日期 //if(string.IsNullOrEmpty(outDateString)) //{ // return ResponseUtil.Error(400, "出访日期不能为空"); //} //else //{ // if(!DateTime.TryParse(outDateString, out outDate)) // { // return ResponseUtil.Error(400, "出访日期格式不正确"); // } //} if (!string.IsNullOrEmpty(outDateString)) { if (!DateTime.TryParse(outDateString, out outDate)) { return(ResponseUtil.Error(400, "出访日期格式不正确")); } } // 履历ID列表 if (string.IsNullOrEmpty(outUsers)) { return(ResponseUtil.Error(400, "出访人员不能为空")); } /* * 更新申请 */ using (var db = new YGSDbContext()) { var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault(); if (apply == null) { return(ResponseUtil.Error(400, "申请不能为空")); } else { // 原有的outUsers //var oldOutUsers = apply.OutUsers.Split(',').ToList().Select(int.Parse).ToList(); // 最新的outUsers //var currentOutUsers = outUsers.Split(',').ToList().Select(int.Parse).ToList(); // 获得筛选掉的用户,并移除 //foreach(int outUid in oldOutUsers) //{ // if (!currentOutUsers.Contains(outUid)) // { // var deleteUser = db.User.Where(n => n.ID == outUid).FirstOrDefault(); // if(deleteUser != null) // { // db.User.Remove(deleteUser); // } // } //} if (!string.IsNullOrEmpty(outDateString)) { apply.OutDate = outDate; } else { apply.OutDate = null; } apply.SignStatus = signStatus; apply.OutUsers = outUsers; db.SaveChanges(); return(ResponseUtil.OK(200, "更新成功")); } } }
public ActionResult DoAdd(FormCollection collection) { /* * 变量定义 */ // 当前用户 var employee = (User.Identity as AppkizIdentity).Employee; /* * 参数获取 */ // 组团名 var outName = collection["outName"]; // 任务描述 var descn = collection["desc"]; // 出访类型 var credType = collection["credType"]; // 出访人员履历 var outUsers = collection["outUsers"]; // 申请附件 var applyAtt = collection["applyAtt"]; /* * 参数校验 */ // 团组名 if (string.IsNullOrEmpty(outName)) { return(ResponseUtil.Error(400, "团组名不能为空")); } // 出访任务 if (string.IsNullOrEmpty(descn)) { return(ResponseUtil.Error(400, "任务描述不能为空")); } // 出访类型 if (string.IsNullOrEmpty(credType)) { return(ResponseUtil.Error(400, "出访类型不能为空")); } // 人员ID列表 if (string.IsNullOrEmpty(outUsers)) { return(ResponseUtil.Error(400, "出访人员不能为空")); } // 申请附件ID不能为空 if (string.IsNullOrEmpty(applyAtt)) { return(ResponseUtil.Error(400, "申请附件不能为空")); } /* * 存储申请 */ using (var db = new YGSDbContext()) { var apply = new YGS_Apply(); apply.OutName = outName; apply.Desc = descn; apply.UserId = employee.EmplID; apply.CredType = credType; apply.OutUsers = outUsers; apply.ApplyAtt = applyAtt; apply.ApplyStatus = WHConstants.Apply_Status_Examing; apply.ApplyDate = DateTime.Now; apply.NextStep = "下载并填写表格"; apply.CreateTime = DateTime.Now; apply.UpdateTime = DateTime.Now; apply.IsDelete = false; db.Apply.Add(apply); db.SaveChanges(); var notifyUserIdList = NotificationUtil.GetNotificationUsers(); foreach (var user in notifyUserIdList) { NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check"); } return(ResponseUtil.OK(200, "创建成功")); } }
public ActionResult DoUpdate(FormCollection collection) { /* * 变量定义 */ // 申请ID int aid = 0; /* * 参数获取 */ // 申请ID var id = collection["id"]; // 团组名 var outName = collection["outName"]; // 出访任务 var descn = collection["desc"]; // 出访类型 var credType = collection["credType"]; // 人员ID列表 var outUsers = collection["outUsers"]; // 申请附件ID列表 var applyAtt = collection["applyAtt"]; // 资料回传附件ID列表 var afterAtt = collection["afterAtt"]; /* * 参数校验 */ // 申请ID if (string.IsNullOrEmpty(id)) { return(ResponseUtil.Error(400, "申请ID不能为空")); } else { if (!int.TryParse(id, out aid)) { return(ResponseUtil.Error(400, "申请ID不正确")); } } // 团组名 if (string.IsNullOrEmpty(outName)) { return(ResponseUtil.Error(400, "团组名不能为空")); } // 出访任务 if (string.IsNullOrEmpty(descn)) { return(ResponseUtil.Error(400, "出访类型不能为空")); } // 人员ID列表 if (string.IsNullOrEmpty(outUsers)) { return(ResponseUtil.Error(400, "出访人员不能为空")); } // 申请附件ID不能为空 if (string.IsNullOrEmpty(applyAtt)) { return(ResponseUtil.Error(400, "申请附件不能为空")); } /* * 查询申请 */ using (var db = new YGSDbContext()) { var apply = db.Apply.Where(n => n.ID == aid).FirstOrDefault(); if (apply == null) { return(ResponseUtil.Error(400, "申请不存在")); } else { apply.OutName = outName; apply.Desc = descn; apply.CredType = credType; apply.OutUsers = outUsers; apply.ApplyAtt = applyAtt; if (!string.IsNullOrEmpty(afterAtt)) { apply.AfterAtt = afterAtt; } else { apply.AfterAtt = null; } // 如果当前申请是被拒绝,则重新到待审核中 if (apply.ApplyStatus == WHConstants.Apply_Status_Rejected) { apply.ApplyStatus = WHConstants.Apply_Status_Examing; var notifyUserIdList = NotificationUtil.GetNotificationUsers(); foreach (var user in notifyUserIdList) { NotificationUtil.SendNotification(user, "您有新的出国申请审核", "/Apps/YGS/Home/Check"); } } db.SaveChanges(); return(ResponseUtil.OK(200, "申请更新成功")); } } }
public ActionResult DoAdd(FormCollection collection) { /* * 变量定义 */ // 性别 int sex = 0; // 出生日期 DateTime birthday = new DateTime(); /* * 参数获取 */ // 姓名 var name = collection["name"]; // 性别 var sexString = collection[@"sex"]; // 出生地 var location = collection["location"]; // 出生日期 var birthDay = collection["birthDay"]; // 身份证号 var credNo = collection["credNo"]; // 工作单位 var unit = collection["unit"]; // 工作部门 var depart = collection["depart"]; // 级别 var level = collection["level"]; // 职务 var duty = collection["duty"]; /* * 参数校验 */ // 姓名 if (string.IsNullOrEmpty(name)) { return(ResponseUtil.Error(400, "姓名不能为空")); } // 性别 if (!string.IsNullOrEmpty(sexString)) { if (int.TryParse(sexString, out sex)) { if (sex != 0 && sex != 1) { return(ResponseUtil.Error(400, "性别错误")); } } else { return(ResponseUtil.Error(400, "性别错误")); } } // 出生地 //if (string.IsNullOrEmpty(location)) //{ // return ResponseUtil.Error(400, "出生地不能为空"); //} // 出生日期 if (!string.IsNullOrEmpty(birthDay)) { if (!DateTime.TryParse(birthDay, out birthday)) { return(ResponseUtil.Error(400, "出生日期无效")); } } // 身份证号 if (!string.IsNullOrEmpty(credNo)) { // 校验身份证格式 if ((!Regex.IsMatch(credNo, @"^(^\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$", RegexOptions.IgnoreCase))) { return(ResponseUtil.Error(400, "身份证格式不正确")); } } // 工作单位 //if (string.IsNullOrEmpty(unit)) //{ // return ResponseUtil.Error(400, "工作单位不能为空"); //} // 工作部门 //if (string.IsNullOrEmpty(depart)) //{ // return ResponseUtil.Error(400, "工作部门不能为空"); //} // 级别 //if (string.IsNullOrEmpty(level)) //{ // return ResponseUtil.Error(400, "级别不能为空"); //} // 职务 //if (string.IsNullOrEmpty(duty)) //{ // return ResponseUtil.Error(400, "职务不能为空"); //} /* * 添加用户 */ using (var db = new YGSDbContext()) { var user = db.User.Where(n => n.CredNo == credNo && !string.IsNullOrEmpty(credNo)).FirstOrDefault(); if (user == null) { user = new YGS_User(); user.Name = name; if (!string.IsNullOrEmpty(sexString)) { user.Sex = sex; } if (!string.IsNullOrEmpty(location)) { user.Location = location; } if (!string.IsNullOrEmpty(birthDay)) { user.BirthDay = birthday; } if (!string.IsNullOrEmpty(credNo)) { user.CredNo = credNo; } if (!string.IsNullOrEmpty(unit)) { user.Unit = unit; } if (!string.IsNullOrEmpty(depart)) { user.Depart = depart; } if (!string.IsNullOrEmpty(level)) { user.Level = level; } if (!string.IsNullOrEmpty(duty)) { user.Duty = duty; } user.CreateTime = DateTime.Now; user.UpdateTime = DateTime.Now; db.User.Add(user); db.SaveChanges(); return(ResponseUtil.OK(200, "创建成功!")); } else { return(ResponseUtil.Error(400, "用户已存在")); } } }
public ActionResult DoAdd(FormCollection collection) { /* * 变量定义 */ // 当前用户 var employee = (User.Identity as AppkizIdentity).Employee; // 出访日期 DateTime outDate = new DateTime(); // 履历IDs List <int> historyIdList = new List <int>(); /* * 参数获取 */ // 组团名 var outName = collection["outName"]; // 任务描述 var descn = collection["desc"]; // 出访类型 var credType = collection["credType"]; // 出访人员履历 var outUsers = collection["outUsers"]; // 出访日期 var outDateString = collection["outDate"]; // 履历ID列表 var historyIds = collection["historyIds"]; /* * 参数校验 */ // 团组名 if (string.IsNullOrEmpty(outName)) { return(ResponseUtil.Error(400, "团组名不能为空")); } // 出访任务 if (string.IsNullOrEmpty(descn)) { return(ResponseUtil.Error(400, "任务描述不能为空")); } // 出访类型 if (string.IsNullOrEmpty(credType)) { return(ResponseUtil.Error(400, "出访类型不能为空")); } // 人员ID列表 if (string.IsNullOrEmpty(outUsers)) { return(ResponseUtil.Error(400, "出访人员不能为空")); } // 出访日期 if (!string.IsNullOrEmpty(outDateString)) { if (!DateTime.TryParse(outDateString, out outDate)) { return(ResponseUtil.Error(400, "出访日期格式不正确")); } } // 履历ID列表 if (!string.IsNullOrEmpty(historyIds)) { historyIdList = historyIds.Split(',').Select(int.Parse).ToList(); } /* * 存储申请 */ using (var db = new YGSDbContext()) { var apply = new YGS_Apply(); apply.OutName = outName; apply.Desc = descn; apply.UserId = employee.EmplID; apply.CredType = credType; apply.OutUsers = outUsers; //apply.ApplyAtt = applyAtt; apply.ApplyStatus = WHConstants.Apply_Status_Passed; apply.ApplyDate = DateTime.Now; apply.NextStep = ""; if (!string.IsNullOrEmpty(outDateString)) { apply.OutDate = outDate; } apply.CreateTime = DateTime.Now; apply.UpdateTime = DateTime.Now; apply.IsDelete = true; db.Apply.Add(apply); db.SaveChanges(); // 更新对应的履历 if (historyIdList.Count > 0) { var histories = db.History.Where(n => historyIdList.Contains(n.ID)).ToList(); foreach (var history in histories) { history.ApplyId = apply.ID; } db.SaveChanges(); } return(ResponseUtil.OK(200, "创建成功")); } }
public ActionResult DoUpdate(FormCollection collection) { /* * 变量定义 */ // 履历ID int id = 0; // 签证时间 DateTime signTime = new DateTime(); // 是否出行 bool isOut = true; /* * 参数获取 */ // 履历ID var idString = collection["id"]; // 签证号 var signNo = collection["signNo"]; // 签证地 var signNation = collection["signNation"]; // 签证时间 var signTimeString = collection["signTime"]; // 是否出行 var isOutString = collection["isOut"]; /* * 参数校验 */ // 履历ID if (string.IsNullOrEmpty(idString)) { return(ResponseUtil.Error(400, "履历ID不能为空")); } else { if (!int.TryParse(idString, out id)) { return(ResponseUtil.Error(400, "履历ID格式不正确")); } } // 签证号 if (string.IsNullOrEmpty(signNo)) { return(ResponseUtil.Error(400, "签证号不能为空")); } // 签证时间 if (!string.IsNullOrEmpty(signTimeString)) { if (!DateTime.TryParse(signTimeString, out signTime)) { return(ResponseUtil.Error(400, "签证时间格式错误")); } } // 是否出行 if (!string.IsNullOrEmpty(isOutString)) { if (!bool.TryParse(isOutString, out isOut)) { return(ResponseUtil.Error(400, "是否出行格式不正确")); } } /* * 更新履历 */ using (var db = new YGSDbContext()) { var history = db.History.Where(n => n.ID == id).FirstOrDefault(); if (history == null) { return(ResponseUtil.Error(400, "履历不存在")); } else { history.SignNo = signNo; // 签证号 if (!string.IsNullOrEmpty(signTimeString)) // 签证时间 { history.SignTime = signTime; } else { history.SignTime = null; } if (!string.IsNullOrEmpty(signNation)) // 签证地 { history.SignNation = signNation; } else { history.SignNation = null; } if (!string.IsNullOrEmpty(isOutString)) { history.IsOut = isOut; // 是否出行 } else { history.IsOut = null; } db.SaveChanges(); return(ResponseUtil.OK(200, "履历更新成功")); } } }