Ejemplo n.º 1
0
        //互助ID标识ContentID、
        public List <VHelpAreaSearchMiddle> GetVHelpAreaSearch(SearchByContentIDModel model)
        {
            VHelpArea Infos = _IVHelpAreaRepository.SearchInfoByID(model.ContentID);
            List <VHelpAreaSearchMiddle> Searches = new List <VHelpAreaSearchMiddle>();
            var SearchMiddlecs = _IMapper.Map <VHelpArea, VHelpAreaSearchMiddle>(Infos);

            Searches.Add(SearchMiddlecs);
            return(Searches);
        }
        // 发布者 确认该志愿者为 认领人(其他人 状态为审核不通过)
        public BaseViewModel SetVHAStatus(string VID, string ContentID)
        {
            VHelpArea area = _IVHelpAreaRepository.SearchInfoByID(ContentID);

            BaseViewModel result = new BaseViewModel();
            //确认 认领人员状态更新为 1(审核通过)、其他人员状态更新为 2(审核不通过);该互助信息 状态改为 1(已认领)
            List <VHA_Sign> list = _IVHA_SignRepository.GetByContentID(ContentID, "1");

            foreach (var item in list)
            {
                //提示信息:您成功认领标题为XXX互助信息,请尽快处理
                Volunteer_MessageMiddle middle         = new Volunteer_MessageMiddle();
                Volunteer_Info          volunteer_Info = new Volunteer_Info();
                if (item.CreateUser == VID)
                {
                    volunteer_Info = _IVolunteerInfoRepository.SearchInfoByID(VID);

                    //确认 认领人员状态更新为 1(审核通过)
                    item.Status     = "1";
                    middle.Contents = "您成功认领标题为 " + area.Title + " 互助信息,请尽快处理";
                }
                else
                {
                    volunteer_Info = _IVolunteerInfoRepository.SearchInfoByID(item.CreateUser);

                    //其他人员状态更新为 2(审核不通过)
                    item.Status     = "2";
                    middle.Contents = "您认领标题为 " + area.Title + " 互助信息,认领不成功,已由其他志愿者处理";
                }
                item.UpdateUser = item.CreateUser;
                item.UpdateDate = DateTime.Now;

                _IVHA_SignRepository.Update(item);
                int a = _IVHA_SignRepository.SaveChanges();

                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 = item.CreateUser;
                message.Status     = "0";

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

            //该互助信息 状态改为 1(已认领)
            var modelVHA = _IVHelpAreaRepository.SearchInfoByID(ContentID);

            modelVHA.Status     = "1";
            modelVHA.UpdateUser = modelVHA.CreateUser;
            modelVHA.UpdateDate = DateTime.Now;
            _IVHelpAreaRepository.Update(modelVHA);
            int b = _IVHelpAreaRepository.SaveChanges();

            if (b > 0)
            {
                result.ResponseCode = 200;
                result.Message      = "操作成功";
            }
            else
            {
                result.ResponseCode = 400;
                result.Message      = "操作失败";
            }

            return(result);
        }