public ActionResult ApplyClubSubmit(string cid) { if (cid == null) { return(RedirectToAction("MyClubs")); } ClubNumber club = db.ClubNumbers.Find(cid); if (club == null) { return(HttpNotFound("未发现社团" + cid)); } ApplyClubSubModel model = new ApplyClubSubModel() { ClubId = club.ClubId, Type = club.Type.Name, Name = club.Name, HeadImg = club.HeadImg, ShortDesc = club.ShortDesc, Desc = club.Desc, State = Enum.GetName(typeof(EnumState), club.State), CreateDate = club.CreateDate == null ? "未知" : club.CreateDate.ToString(), User = club.User.UserName }; return(View(model)); }
public ActionResult ApplyClubSubmit([Bind(Include = "ClubId,ApplyDesc,ApplyFile")] ApplyClubSubModel model) { try { ClubNumber club = db.ClubNumbers.Find(model.ClubId); if (string.IsNullOrWhiteSpace(model.ApplyFile)) { ModelState.AddModelError("", "申请任务未上传审批文件!"); return(View(model)); } if (club.User.UserId != User.Identity.Name) { ModelState.AddModelError("", "非用户" + User.Identity.Name + "创建的申请不能由用户" + User.Identity.Name + "提交!"); return(View(model)); } if (club.State != (int)EnumState.待提交) { ModelState.AddModelError("", "请求状态错误不允许提交审批"); return(View(model)); } ApplyAudit apply = new ApplyAudit() { Type = db.ApplyTypes.Find((int)SQType.注册社团), ApplicationDesc = model.ApplyDesc, ApplicationFiled = model.ApplyFile, ApplyUser = club.User, Club = club, ApplyDate = DateTime.Now, CheckState = (int)EnumAuditState.创建, AuditTimes = 0 }; db.ApplyAudits.Add(apply); db.SaveChanges(); AuditDetail audit = new AuditDetail() { ApplyId = apply.Id, CheckState = (int)EnumAuditState.创建, AuditUser = club.User, AuditDate = DateTime.Now }; db.AuditDetails.Add(audit); club.State = (int)EnumState.待审批; club.AuditID = apply.Id; if (string.IsNullOrEmpty(club.HeadImg)) { club.HeadImg = "Content/images/head5.jpg";//设置社团默认头像图片 } db.Entry(club).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(RedirectToAction("MyClubs", new { Msg = "社团编号[" + club.ClubId + "]一个申请已提交,牢记并使用申请任务凭证[" + apply.Id + "]查看申请进度" })); } catch (Exception ex) { ModelState.AddModelError("", ex.Message); return(View(model)); } }
public ActionResult AuditClubA(int?id) { if (id == null) { Session["Error"] = "未找到指定的社团申请"; return(RedirectToAction("Error404", "Home")); } ApplyAudit AppA = db.ApplyAudits.Find(id); if (AppA == null) { Session["Error"] = "未找到指定的社团申请" + id; return(RedirectToAction("Error404", "Home")); } ClubNumber club = AppA.Club; if (club == null) { Session["Error"] = "未从申请任务[" + id + "]中发现社团信息"; return(RedirectToAction("Error404", "Home")); } ApplyClubSubModel model = new ApplyClubSubModel() { ClubId = club.ClubId, Type = club.Type.Name, Name = club.Name, HeadImg = club.HeadImg, ShortDesc = club.ShortDesc, Desc = club.Desc, State = Enum.GetName(typeof(EnumState), club.State), CreateDate = club.CreateDate == null ? "未知" : club.CreateDate.ToString(), User = club.User.UserName, ApplyDesc = AppA.ApplicationDesc, ApplyFile = AppA.ApplicationFiled, AuditDate = AppA.AuditDate == null ? "未知" : AppA.AuditDate.ToString(), AuditTime = AppA.AuditTimes ?? 0, AuditId = AppA.Id }; return(View(model)); }