public ActionResult ProjectIdentityRecordApprove(Guid? id, bool isApprove)
        {
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            Project project = db.Projects.Find(id);
            if (project == null)
                return new HttpStatusCodeResult(HttpStatusCode.NotFound);
            if (project.Status != ProjectStatus.ToApprove)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            if (isApprove)
            {
                project.Status = ProjectStatus.Done;
                db.Messages.Add(new Message(project.Admin.Id, MessageType.System, MessageTemplate.ProjectSuccess, ref db));
                Team team = new Team();
                team.NewTeam(ref project);
                db.TeamRecords.Add(new TeamRecord(team, TeamMemberStatus.Admin, project.Admin));
                db.TeamEvents.Add(new TeamEvent { Id = Guid.NewGuid(), AddTime = DateTime.Now, EventTime = DateTime.Now, EventContent = "通过管理员审批,在本网站上开始招募团队。", EventName = "创建团队", Team = team });
            }
            else
            {
                project.Status = ProjectStatus.Denied;
                db.Messages.Add(new Message(project.Admin.Id, MessageType.System, MessageTemplate.ProjectFailure, ref db));
            }
            db.SaveChanges();
            return RedirectToAction("ProjectIdentityRecords");
        }
示例#2
0
        public ActionResult ProjectIdentityRecordApprove(Guid? id, bool isApprove)
        {
            if (id == null)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

            Project project = db.Projects.Find(id);
            if (project == null)
                return new HttpStatusCodeResult(HttpStatusCode.NotFound);
            if (project.Status != ProjectStatus.ToApprove)
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            if (isApprove)
            {
                project.Status = ProjectStatus.Done;
                db.Messages.Add(new Message(project.Admin.Id, MessageType.System, MessageTemplate.ProjectSuccess, db));
                Team Team = new Team();
                Team.NewTeam(ref project);
            }
            else
            {
                project.Status = ProjectStatus.Denied;
                db.Messages.Add(new Message(project.Admin.Id, MessageType.System, MessageTemplate.ProjectFailure, db));
            }
            db.SaveChanges();
            return RedirectToAction("ProjectIdentityRecords");
        }