public BaseViewModel AddMessages(Volunteer_MessageMiddle model)
        {
            BaseViewModel res = new BaseViewModel();

            Volunteer_Message message = _IMapper.Map <Volunteer_MessageMiddle, Volunteer_Message>(model);

            message.ID         = Guid.NewGuid().ToString();
            message.CreateDate = DateTime.Now;
            message.CreateUser = model.VID;
            message.Status     = "0";

            _IVolunteer_MessageRepository.Add(message);
            int a = _IVolunteer_MessageRepository.SaveChanges();

            if (a > 0)
            {
                res.ResponseCode = 200;
                res.Message      = "消息推送成功";
            }
            else
            {
                res.ResponseCode = 400;
                res.Message      = "消息推送失败";
            }
            return(res);
        }
        //社区居民上传互助信息(名称、内容、所需擅长技能、姓名、联系方式、详细地址、可得积分)
        public BaseViewModel AddHelpArea(VHelpAreaSearchMiddle area)
        {
            BaseViewModel result   = new BaseViewModel();
            VHelpArea     helpArea = _IMapper.Map <VHelpAreaSearchMiddle, VHelpArea>(area);

            helpArea.ID         = Guid.NewGuid().ToString();
            helpArea.CreateDate = DateTime.Now;
            helpArea.UpdateDate = DateTime.Now;
            helpArea.Status     = "9";
            _IVHelpAreaRepository.Add(helpArea);
            int a = _IVHelpAreaRepository.SaveChanges();

            if (a > 0)
            {
                //提示信息:您已发布标题为XXX互助信息,等待审核
                Volunteer_MessageMiddle middle = new Volunteer_MessageMiddle();
                middle.Contents = "您已上传标题为 " + area.Title + " 互助信息,等待审核";

                Volunteer_Info volunteer_Info = _IVolunteerInfoRepository.SearchInfoByID(area.CreateUser);
                middle.Name = volunteer_Info.Name;
                middle.VID  = volunteer_Info.ID;
                middle.VNO  = volunteer_Info.VNO;

                Volunteer_Message message = _IMapper.Map <Volunteer_MessageMiddle, Volunteer_Message>(middle);
                message.ID         = Guid.NewGuid().ToString();
                message.CreateDate = DateTime.Now;
                message.CreateUser = area.CreateUser;
                message.Status     = "0";

                _IVolunteer_MessageRepository.Add(message);
                int c = _IVolunteer_MessageRepository.SaveChanges();

                result.ResponseCode = 200;
                result.Message      = "上传成功,等待审核";
            }
            else
            {
                result.ResponseCode = 400;
                result.Message      = "上传失败,请重新操作";
            }
            return(result);
        }
Exemplo n.º 3
0
        //志愿者互助信息认领提交
        public int SignAdd(VHA_SignAddViewModel AddViewModel)
        {
            //普通志愿者  无擅长技能
            string SkillID = "AB1EC380-4D47-45AB-9C2B-F2EE19B7AE9C";
            //区外小区
            string CommunityID = "D6E82522-7D21-44EF-BC81-31CAC7DA19CE";

            int count = 0;

            if (String.IsNullOrEmpty(AddViewModel.ContentID) || String.IsNullOrEmpty(AddViewModel.VID) || String.IsNullOrEmpty(AddViewModel.TypeID))
            {
                count = 7;
                return(count);
            }


            ///发布者不能认领自己发布的互助任务
            VHelpArea area = _IVHelpAreaRepository.SearchInfoByID(AddViewModel.ContentID);

            if (area.CreateUser == AddViewModel.VID)
            {
                count = 5;
                return(count);
            }

            var model         = _IMapper.Map <VHA_SignAddViewModel, VHA_Sign>(AddViewModel);
            var VolunteerInfo = _IVolunteerInfoRepository.SearchInfoByID(model.VID);

            if (VolunteerInfo == null)
            {
                count = 6;
                return(count);
            }


            //判断是否是   泰达街社区居民或机关单位工作人员  认领
            if (VolunteerInfo.CommunityID == CommunityID && VolunteerInfo.UnitID == "")
            {
                count = 8;
                return(count);
            }

            //判断 志愿类型 判断是否是 普通志愿者
            if (AddViewModel.TypeID != SkillID)
            {
                //判断 是否是专业志愿服务 则需验证 报名者是否符合
                if (_IBaseTypeRepository.CheckStatus(AddViewModel.TypeID))
                {
                    //判断是否有该类型资质认证
                    if (!_IVolunteer_Relate_TypeRepository.CheckInfo(AddViewModel.TypeID, AddViewModel.VID))
                    {
                        count = 9;
                        return(count);
                    }
                }
            }


            model.ID          = Guid.NewGuid().ToString();
            model.VNO         = VolunteerInfo.VNO;
            model.Participant = VolunteerInfo.Name;
            model.Status      = "0";
            model.flag        = "1";
            model.CreateUser  = VolunteerInfo.ID;
            model.CreateDate  = DateTime.Now;
            _IVHA_SignRepository.Add(model);
            count = _IVHA_SignRepository.SaveChanges();

            //提示信息:您已认领XXX互助信息,等待审核
            Volunteer_MessageMiddle middle = new Volunteer_MessageMiddle();

            middle.Contents = "您已认领标题为 " + area.Title + " 互助信息,等待审核";
            middle.Name     = VolunteerInfo.Name;
            middle.VID      = VolunteerInfo.ID;
            middle.VNO      = VolunteerInfo.VNO;

            Volunteer_Message message = _IMapper.Map <Volunteer_MessageMiddle, Volunteer_Message>(middle);

            message.ID         = Guid.NewGuid().ToString();
            message.CreateDate = DateTime.Now;
            message.CreateUser = model.VID;
            message.Status     = "0";

            _IVolunteer_MessageRepository.Add(message);
            int a = _IVolunteer_MessageRepository.SaveChanges();

            return(count);
        }
        //(小程序端接口) 志愿者上传 公益秀(志愿活动ID,活动标题,活动地址,参与感受,图片列表 等等)
        public VActivity_PublicShowAddResModel AddPublicShow(VActivity_PublicShowAddModel showAddModel)
        {
            VActivity_PublicShowAddResModel result = new VActivity_PublicShowAddResModel();
            VActivity_PublicShow            show   = _IMapper.Map <VActivity_PublicShowAddModel, VActivity_PublicShow>(showAddModel);

            if (string.IsNullOrEmpty(showAddModel.ContentID) || string.IsNullOrEmpty(showAddModel.VID) ||
                string.IsNullOrEmpty(showAddModel.Address))
            {
                result.AddCount                   = 0;
                result.IsSuccess                  = false;
                result.baseViewModel.Message      = "上传公益秀信息失败,参数为空";
                result.baseViewModel.ResponseCode = 500;
            }
            else
            {
                var VolunteerInfo = _IVolunteerInfoRepository.SearchInfoByID(showAddModel.VID);
                if (VolunteerInfo == null)
                {
                    result.AddCount                   = 0;
                    result.IsSuccess                  = false;
                    result.baseViewModel.Message      = "上传公益秀基本信息失败";
                    result.baseViewModel.ResponseCode = 500;
                    return(result);
                }

                show.ID         = Guid.NewGuid().ToString();
                show.NickName   = VolunteerInfo.Nickname;
                show.Headimgurl = VolunteerInfo.Headimgurl;
                show.CreateUser = showAddModel.VID;
                show.CreateDate = DateTime.Now;
                show.UpdateUser = showAddModel.VID;
                show.UpdateDate = DateTime.Now;
                show.Status     = "0";
                _IVActivity_PublicShowRepository.Add(show);
                int a = _IVActivity_PublicShowRepository.SaveChanges();
                if (a > 0)
                {
                    int c = 0;
                    //保存 公益秀图片
                    var AttachmentInfo = _IMapper.Map <List <VAttachmentAddViewModel>, List <VAttachment> >(showAddModel.VAttachmentAddList);
                    foreach (var item in AttachmentInfo)
                    {
                        item.ID         = Guid.NewGuid().ToString();
                        item.formid     = show.ID;
                        item.type       = "PSTP";
                        item.Status     = "0";
                        item.CreateUser = showAddModel.VID;
                        item.CreateDate = DateTime.Now;
                        _IVAttachmentRepository.Add(item);
                        c = _IVAttachmentRepository.SaveChanges() + c;
                    }
                    if (c == showAddModel.VAttachmentAddList.Count)
                    {
                        //提示信息:您成功上传公益秀,等待审核。
                        Volunteer_MessageMiddle middle = new Volunteer_MessageMiddle();
                        middle.Contents = "您上传标题为 " + showAddModel.Title + " 公益秀,等待审核。";

                        Volunteer_Info volunteer_Info = _IVolunteerInfoRepository.SearchInfoByID(showAddModel.VID);
                        middle.Name = volunteer_Info.Name;
                        middle.VID  = volunteer_Info.ID;
                        middle.VNO  = volunteer_Info.VNO;

                        Volunteer_Message message = _IMapper.Map <Volunteer_MessageMiddle, Volunteer_Message>(middle);
                        message.ID         = Guid.NewGuid().ToString();
                        message.CreateDate = DateTime.Now;
                        message.CreateUser = showAddModel.VID;
                        message.Status     = "0";

                        _IVolunteer_MessageRepository.Add(message);
                        int f = _IVolunteer_MessageRepository.SaveChanges();



                        result.AddCount                   = a;
                        result.IsSuccess                  = true;
                        result.baseViewModel.Message      = "成功上传公益秀,等待审核。";
                        result.baseViewModel.ResponseCode = 200;
                    }
                    else
                    {
                        result.AddCount                   = 0;
                        result.IsSuccess                  = false;
                        result.baseViewModel.Message      = "上传公益秀图片失败";
                        result.baseViewModel.ResponseCode = 300;
                    }
                }
                else
                {
                    result.AddCount                   = 0;
                    result.IsSuccess                  = false;
                    result.baseViewModel.Message      = "上传公益秀基本信息失败";
                    result.baseViewModel.ResponseCode = 400;
                }
            }


            return(result);
        }