コード例 #1
0
ファイル: ActiveController.cs プロジェクト: Ivanhuan/Clubs
        public ActionResult Submit(string aid)
        {
            if (aid == null || (int.TryParse(aid, out int intaid) == false))
            {
                return(RedirectToAction("Manage"));
            }
            Activities act = db.Activities.Find(intaid);

            if (act == null)
            {
                Session["Error"] = "未发现活动" + aid;
                return(RedirectToAction("Error404", "Home"));
            }
            if (act.User.UserId != User.Identity.Name)
            {
                Session["Error"] = "访问被拒绝!编号为" + aid + "的活动非当前登陆用户创建";
                return(RedirectToAction("Error404", "Home"));
            }
            ActiveSubModel model = new ActiveSubModel()
            {
                Id      = act.Id,
                Type    = act.Type.ToString(),
                State   = Enum.GetName(typeof(ActiveState), act.State),
                Title1  = act.Title1,
                Title2  = act.Title2,
                Content = act.Content,
                Area    = act.Area == null ? act.Area0 : act.Area.Name,
                Time1   = act.Time1.ToString(),
                Time2   = act.Time2.ToString(),
                MaxUser = act.MaxUser == null ? "无限制" : act.MaxUser.ToString(),
                Labels  = act.Label?.Split(',').ToList()
            };

            return(View(model));
        }
コード例 #2
0
        public ActionResult AuditActA(string id)
        {
            if (id == null || (int.TryParse(id, out int intaid) == false))
            {
                return(RedirectToAction("Manage"));
            }
            Activities act = db.Activities.Where(a => a.AuditID == intaid).FirstOrDefault();

            if (act == null)
            {
                Session["Error"] = "未发现活动" + id;
                return(RedirectToAction("Error404", "Home"));
            }
            if (act.User.UserId != User.Identity.Name)
            {
                Session["Error"] = "访问被拒绝!编号为" + id + "的活动非当前登陆用户创建";
                return(RedirectToAction("Error404", "Home"));
            }
            ApplyAudit     AppA  = db.ApplyAudits.Find(intaid);
            ActiveSubModel model = new ActiveSubModel()
            {
                Id        = act.Id,
                Type      = act.Type.ToString(),
                State     = Enum.GetName(typeof(ActiveState), act.State),
                Title1    = act.Title1,
                Title2    = act.Title2,
                Content   = act.Content,
                Area      = act.Area == null ? act.Area0 : act.Area.Name,
                Time1     = act.Time1.ToString(),
                Time2     = act.Time2.ToString(),
                MaxUser   = act.MaxUser == null ? "无限制" : act.MaxUser.ToString(),
                Labels    = act.Label?.Split(',').ToList(),
                ApplyDesc = AppA.ApplicationDesc,
                ApplyFile = AppA.ApplicationFiled,
                AuditDate = AppA.AuditDate == null ? "未知" : AppA.AuditDate.ToString(),
                AuditTime = AppA.AuditTimes ?? 0,
                AuditId   = AppA.Id
            };

            return(View(model));
        }
コード例 #3
0
ファイル: ActiveController.cs プロジェクト: Ivanhuan/Clubs
        public ActionResult Submit([Bind(Include = "Id,ApplyDesc,ApplyFile")] ActiveSubModel model)
        {
            Activities act = db.Activities.Find(model.Id);

            if (act == null)
            {
                Session["Error"] = "未发现活动" + model.Id;
                return(RedirectToAction("Error404", "Home"));
            }
            ActiveSubModel model1 = new ActiveSubModel()
            {
                Id      = act.Id,
                Type    = act.Type.ToString(),
                State   = Enum.GetName(typeof(ActiveState), act.State),
                Title1  = act.Title1,
                Title2  = act.Title2,
                Content = act.Content,
                Area    = act.Area == null ? act.Area0 : act.Area.Name,
                Time1   = act.Time1.ToString(),
                Time2   = act.Time2.ToString(),
                MaxUser = act.MaxUser == null ? "无限制" : act.MaxUser.ToString(),
                Labels  = act.Label?.Split(',').ToList()
            };

            try
            {
                if (string.IsNullOrWhiteSpace(model.ApplyFile))
                {
                    ModelState.AddModelError("", "申请任务未上传审批文件!");
                    return(View(model1));
                }
                if (act.User.UserId != User.Identity.Name)
                {
                    ModelState.AddModelError("", "非用户" + User.Identity.Name + "创建的活动不能由用户" + User.Identity.Name + "提交!");
                    return(View(model1));
                }
                if (act.State != (int)ActiveState.待提交)
                {
                    ModelState.AddModelError("", "请求状态错误不允许提交审批");
                    return(View(model1));
                }
                ApplyType type = db.ApplyTypes.Find((int)SQType.创建活动);
                if (type == null || type.Enable != 1)
                {
                    ModelState.AddModelError("", "活动创建申请通道未启用,请联系管理员");
                    return(View(model1));
                }

                ApplyAudit apply = new ApplyAudit()
                {
                    Type             = db.ApplyTypes.Find((int)SQType.创建活动),
                    ApplicationDesc  = model.ApplyDesc,
                    ApplicationFiled = model.ApplyFile,
                    ApplyUser        = act.User,
                    Club             = act.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  = act.User,
                    AuditDate  = DateTime.Now
                };
                db.AuditDetails.Add(audit);

                act.State   = (int)ActiveState.待审批;
                act.AuditID = apply.Id;

                db.Entry(act).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Manage", "Clubs", new { cid = act.Club.ClubId }));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(View(model1));
            }
        }