示例#1
0
        public List <InvitationDto> Getinv()
        {
            IEnumerable <Invitation> invitations = _IS.GetAllInvites();
            List <InvitationDto>     vaDtos      = new List <InvitationDto>();


            foreach (Invitation a in invitations)
            {
                InvitationDto vd = new InvitationDto();
                vd.InvitationId = a.InvitationId;
                vd.Status       = a.Status;
                vd.VolunteerId  = a.VolunteerId;
                vd.ActionId     = a.ActionId;
                VoluntaryActionDto vDA = new VoluntaryActionDto();
                VolunteerDto       vDt = new VolunteerDto();

                var V = _IS.GetDataOfInvite(a.VolunteerId);
                var A = _IS.GetActionV(a.ActionId);
                foreach (VoluntaryAction Ac in A)
                {
                    vDA.ActionId  = Ac.ActionId;
                    vDA.Name      = Ac.Name;
                    vDA.StartDate = Ac.StartDate;
                    vDA.EndDate   = Ac.EndDate;
                    vd.Actions.Add(vDA);
                }

                foreach (Volunteer v in V)
                {
                    vDt.VolunteerId = v.Id;
                    vDt.UserName    = v.UserName;
                    vDt.UserEmail   = v.Email;
                    vd.Volunteers.Add(vDt);
                }
                vaDtos.Add(vd);
            }


            return(vaDtos);
        }
        // GET: api/Action
        public List <VoluntaryActionDto> GetAllActions()
        {
            IQueryable actions = vas.GetAllActions();
            List <VoluntaryActionDto> vaDtos = new List <VoluntaryActionDto>();


            foreach (VoluntaryAction a in actions)
            {
                VoluntaryActionDto vd = new VoluntaryActionDto();
                vd.ActionId      = a.ActionId;
                vd.Name          = a.Name;
                vd.Address       = a.Address;
                vd.Description   = a.Description;
                vd.StartDate     = a.StartDate;
                vd.EndDate       = a.EndDate;
                vd.ActionType    = a.ActionType;
                vd.MaxVolunteers = a.MaxVolunteers;
                vd.CreatorNgoId  = a.CreatorNgoId;

                foreach (Volunteer v in a.Participants)
                {
                    UserDto vDt = new UserDto();
                    vDt.Id          = v.Id;
                    vDt.Name        = v.Name;
                    vDt.Email       = v.Email;
                    vDt.PhoneNumber = v.PhoneNumber;
                    vDt.Role        = "Volunteer";
                    vd.Participants.Add(vDt);
                }
                vaDtos.Add(vd);
            }



            return(vaDtos);
        }