コード例 #1
0
        public ActionResult <List <EditNeedDTO> > Get(string id)
        {
            List <EditNeedDTO> ListUnassignedDTO = new List <EditNeedDTO>();
            var user = _userService.GetUser(id);

            if (user == null)
            {
                return(NotFound());
            }

            ISet <ObjectId> AssignedNeedsSet = new HashSet <ObjectId>(user.NeedsIds);

            _needsService.Get().ForEach(need =>
            {
                if (!AssignedNeedsSet.Contains(new ObjectId(need.Id)) && need.State == Utils.Utils.NEED_STATE_UNASSIGNED)
                {
                    EditNeedDTO EDT = new EditNeedDTO()
                    {
                        Title       = need.Title,
                        Description = need.Description,
                        Date        = need.Date,
                        State       = need.State,
                        City        = user.Address,
                        Id          = need.Id
                    };
                    ListUnassignedDTO.Add(EDT);
                }
            });

            return(ListUnassignedDTO);
        }
コード例 #2
0
        public ActionResult <EditNeedDTO> GetNeed(string id)
        {
            var need = _needsService.GetNeed(id);

            if (need == null)
            {
                return(NotFound());
            }
            var UserNeed = _userService.GetUser(need.UserId.ToString());


            if (UserNeed == null)
            {
                return(NotFound());
            }

            EditNeedDTO needDTO = new EditNeedDTO
            {
                Title       = need.Title,
                Description = need.Description,
                Date        = need.Date,
                State       = need.State,
                City        = UserNeed.Address
            };

            return(needDTO);
        }
コード例 #3
0
        public ActionResult <List <EditNeedDTO> > GetDoneVolunteerNeeds(string id)
        {
            var user = _userService.GetUser(id);

            if (user == null)
            {
                return(NotFound());
            }

            List <EditNeedDTO> ListOfDone = new List <EditNeedDTO>();

            System.Diagnostics.Debug.WriteLine(user.NeedsIds.Count);

            user.NeedsIds.ForEach(id =>
            {
                var need = _needsService.GetNeed(id.ToString());
                if (need != null && need.State == Utils.Utils.NEED_STATE_DONE)
                {
                    EditNeedDTO NeedDTO = new EditNeedDTO
                    {
                        Description = need.Description,
                        Date        = need.Date,
                        Title       = need.Title,
                        State       = need.State,
                        City        = user.Address,
                        Id          = need.Id
                    };
                    ListOfDone.Add(NeedDTO);
                }
            }
                                  );

            return(ListOfDone);
        }