public ActionResult Index(string kw = null, string projectId = null, int pageIndex = 1)
        {
            var seh = new SenparcExpressionHelper <CompetitionProgram>();

            seh.ValueCompare.AndAlso(true, z => !z.Flag)
            .AndAlso(!projectId.IsNullOrEmpty(), z => z.ScheduleId == projectId)
            .AndAlso(!kw.IsNullOrEmpty(), z => z.Name.Contains(kw) || z.Company.Contains(kw) || z.SignNum.Contains(kw) || z.Remark.Contains(kw) || z.Desc.Contains(kw));


            var where = seh.BuildWhereExpression();

            var activies = _activityService.GetFullList(x => x.IsPublish, x => x.IsPublish, OrderingType.Descending).ToList();

            if (activies.Count < 1)
            {
                base.SetMessager(MessageType.danger, "请先完善活动主题");
                return(RedirectToAction("Index"));
            }
            var curactivity = activies.Select(x => x.Id).ToList();

            // List<Schedule> list = new List<Schedule>();

            var clist = _scheduleService.GetFullList(x => curactivity.Contains(x.ActivityId), x => x.Sort, OrderingType.Ascending).ToList().Select(x => x).ToList();


            var modelList = _competitionProgramService.GetObjectList(pageIndex, 10000, where, z => z.Id, OrderingType.Descending);

            List <CompetitionProgram_EditVD> list = new List <CompetitionProgram_EditVD>();

            modelList.ForEach(x =>
            {
                var leader = new ProjectMember();

                if (!string.IsNullOrEmpty(x.ControlId))
                {
                    var cleader = _projectMemberService.GetObject(xp => xp.IsLeader && xp.ProjectId == x.Id);

                    if (cleader != null)
                    {
                        leader = cleader;
                    }
                }

                var strcateName = string.Empty;

                if (x.Schedule == null)
                {
                    x.Schedule = _scheduleService.GetObject(s => s.Id == x.ScheduleId);
                }

                list.Add(new CompetitionProgram_EditVD
                {
                    ActivityId   = x.Schedule.ActivityId,
                    BdImgUrl     = x.BdImgUrl,
                    BdImgUrlPwd  = x.BdImgUrlPwd,
                    Cate         = x.Cate,
                    ScheduleName = x.Schedule.Name,
                    //CategoryName = string.Empty,
                    Company     = x.Company,
                    ControlId   = x.ControlId,
                    CreateTime  = x.CreateTime,
                    CreatorId   = x.CreatorId,
                    CreatorName = x.CreatorName,
                    Desc        = x.Desc,
                    Id          = x.Id,
                    ImgUrl      = x.ImgUrl,
                    LeaderCom   = leader.Company,
                    LeaderDuty  = leader.Duty,
                    LeaderName  = leader.Name,
                    Name        = x.Name,
                    Remark      = x.Remark,
                    ProjectId   = x.ScheduleId,
                    SignNum     = x.SignNum,
                    Status      = x.Status,
                    UpdateTime  = x.UpdateTime,
                    UpdatorId   = x.UpdatorId,
                    UpdatorName = x.UpdatorName,
                    Flag        = x.Flag,
                });
            });

            var vd = new CompetitionProgram_IndexVD()
            {
                CompetitionProgramList = new PagedList <CompetitionProgram_EditVD>(list, pageIndex, modelList.PageCount, modelList.TotalCount, modelList.SkipCount),
                kw        = kw,
                ProjectId = projectId,
                Schedules = clist
            };

            return(View(vd));
        }
Пример #2
0
        /// <summary>
        /// 添加项目成员
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public ActionResult AddMember(AddProjectMemberRequest request, string session)
        {
            try
            {
                AdminUserInfo adminUser = null;
                adminUser = VerifySession(session, adminUser, _adminUserInfoService);
                if (adminUser == null)
                {
                    return(Json(new
                    {
                        code = -1,
                        msg = "请先登录",
                        data = new
                        {
                        }
                    }));
                }
                var curactivity = _activityService.GetFullList(x => x.IsPublish, x => x.IssueTime, Core.Enums.OrderingType.Descending).FirstOrDefault();
                if (curactivity == null)
                {
                    return(Json(new
                    {
                        code = -1,
                        msg = "暂时没有活动可参与",
                        data = new
                        {
                        }
                    }));
                }
                var scheduleList = _scheduleService.GetFullList(x => x.ActivityId == curactivity.Id, x => x.StartTime, Core.Enums.OrderingType.Ascending).Select(x => x.Id);
                if (scheduleList.Count() == 0)
                {
                    if (curactivity == null)
                    {
                        return(Json(new
                        {
                            code = -1,
                            msg = "主办方未安排赛程",
                            data = new
                            {
                            }
                        }));
                    }
                }

                //var pm = _projectMemberService.GetObject(x => x.ProjectId == request.ProjectId && x.Phone == request.Phone);

                ProjectMember pm = null;
                if (!string.IsNullOrEmpty(request.Id))
                {
                    pm = _projectMemberService.GetObject(x => x.Id == request.Id);

                    if (pm == null)
                    {
                        return(Json(new
                        {
                            code = -1,
                            msg = "指定用户不存在",
                            data = new { }
                        }));
                    }
                }

                if (pm != null)
                {
                    // pm.Id = Guid.NewGuid().ToString("N");
                    pm.Company = request.Company;
                    pm.Duty    = request.Duty;
                    pm.Email   = request.Email;
                    //pm.CreateTime = DateTime.Now;
                    pm.Flag       = false;
                    pm.Gender     = request.Gender;
                    pm.Name       = request.Name;
                    pm.Nation     = request.Nation;
                    pm.ProjectId  = request.ProjectId;
                    pm.Phone      = request.Phone;
                    pm.UpdateTime = DateTime.Now;
                    pm.IsLeader   = request.IsLeader;
                    pm.IdCard     = request.IdCard;
                    pm.Sort       = pm.Sort;
                }

                else
                {
                    var count = _projectMemberService.GetFullList(x => x.ProjectId == request.ProjectId && x.Phone == request.Phone, x => x.CreateTime, OrderingType.Descending).Count;

                    pm = new ProjectMember
                    {
                        Id         = Guid.NewGuid().ToString("N"),
                        Company    = request.Company,
                        Duty       = request.Duty,
                        Email      = request.Email,
                        CreateTime = DateTime.Now,
                        Flag       = false,
                        Gender     = request.Gender,
                        Name       = request.Name,
                        Nation     = request.Nation,
                        ProjectId  = request.ProjectId,
                        Phone      = request.Phone,
                        UpdateTime = DateTime.Now,
                        IsLeader   = request.IsLeader,
                        IdCard     = request.IdCard,
                        Sort       = count + 1,
                    };
                }

                _projectMemberService.SaveObject(pm);


                return(Json(new
                {
                    code = 0,
                    msg = "添加成功",
                    data = new {
                        pm.Id,
                        pm.IdCard,
                        pm.Name,
                        pm.Phone,
                        pm.ProjectId,
                        pm.IdCardImgUrl
                    }
                }));
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    code = -1,
                    msg = "服务器异常",
                    data = new { }
                }));
            }
        }
Пример #3
0
        public ActionResult Edit(string id)
        {
            bool isEdit = !string.IsNullOrEmpty(id);
            var  vd     = new ProjectMember_EditVD();


            var activies = _activityService.GetFullList(x => x.IsPublish, x => x.IsPublish, OrderingType.Descending).ToList();

            if (activies.Count < 1)
            {
                base.SetMessager(MessageType.danger, "请先完善活动主题");
                return(RedirectToAction("Index"));
            }
            var curactivity = activies.Select(x => x.Id).ToList();

            // List<Schedule> list = new List<Schedule>();

            var list = _scheduleService.GetFullList(x => curactivity.Contains(x.ActivityId), x => x.Sort, OrderingType.Ascending).ToList().Select(x => x.Id).ToList();

            var modellist = _competitionProgramService.GetFullList(x => list.Contains(x.ScheduleId), x => x.CreateTime, OrderingType.Descending).Select(x => x).ToList();

            if (isEdit)
            {
                var model = _projectMemberService.GetObject(z => z.Id == id);
                if (model == null)
                {
                    base.SetMessager(MessageType.danger, "信息不存在!");
                    return(RedirectToAction("Index"));
                }

                vd.Name       = model.Name;
                vd.Id         = model.Id;
                vd.IdCard     = model.IdCard;
                vd.Nation     = model.Nation;
                vd.Phone      = model.Phone;
                vd.ProjectId  = model.ProjectId;
                vd.Sort       = model.Sort;
                vd.IsLeader   = model.IsLeader;
                vd.Gender     = model.Gender;
                vd.Duty       = model.Duty;
                vd.Email      = model.Email;
                vd.Company    = model.Company;
                vd.HeadImgUrl = model.HeadImgUrl;
                vd.CreateTime = model.CreateTime;
                vd.UpdateTime = model.UpdateTime;
            }
            else
            {
            }

            if (modellist.Count == 0)
            {
                base.SetMessager(MessageType.danger, "没有参赛项目");
                return(RedirectToAction("Index"));
            }

            vd.CompetitionPrograms = modellist;
            //vd.Schedules = list;

            vd.IsEdit = isEdit;
            return(View(vd));
        }