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, "申请更新成功")); } } }