//GET: Volunteer/Details/5
        public ActionResult Details(int id)
        {
            ShowVolunteer       ViewModel = new ShowVolunteer();
            string              url       = "volunteerdata/findvolunteer/" + id;
            HttpResponseMessage response  = client.GetAsync(url).Result;

            //Catch the status code (200 OK, 301 REDIRECT), etc.

            if (response.IsSuccessStatusCode)
            {
                //Volunteer goes in Data Transfer Object
                VolunteerDto SelectedVolunteer = response.Content.ReadAsAsync <VolunteerDto>().Result;
                ViewModel.volunteer = SelectedVolunteer;
                Debug.WriteLine("SelectedVolunteer:" + SelectedVolunteer.VolunteerHasPic);

                url      = "DepartmentData/FindDepartment/" + SelectedVolunteer.DepartmentID;
                response = client.GetAsync(url).Result;
                DepartmentDto SelectedDepartment = response.Content.ReadAsAsync <DepartmentDto>().Result;
                ViewModel.department = SelectedDepartment;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
        //GET: Volunteer/Edit/8
        public ActionResult Edit(int id)
        {
            UpdateVolunteer ViewModel = new UpdateVolunteer();

            string url = "volunteerdata/findvolunteer/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;


            if (response.IsSuccessStatusCode)
            {
                //Put data into volunteer data transfer object
                VolunteerDto SelectedVolunteer = response.Content.ReadAsAsync <VolunteerDto>().Result;
                ViewModel.volunteer = SelectedVolunteer;

                //get information about departments this volunteer could also be in
                url      = "departmentdata/listdepartments";
                response = client.GetAsync(url).Result;
                IEnumerable <DepartmentDto> PotentialDepartments = response.Content.ReadAsAsync <IEnumerable <DepartmentDto> >().Result;
                ViewModel.alldepartments = PotentialDepartments;

                return(View(ViewModel));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Example #3
0
        public bool Post([FromBody] VolunteerDto volunteermodel)
        {
            var volunteer = _mapper.Map <Volunteer>(volunteermodel);
            var register  = _volunteerservice.AddVolunteer(volunteer);

            return(register);
        }
        public IHttpActionResult FindVolunteer(int id)
        {
            //Find the data
            Volunteer Volunteer = db.Volunteers.Find(id);
            //if not found, return 404 status code.
            if (Volunteer == null)
            {
                return NotFound();
            }


            VolunteerDto VolunteerDto = new VolunteerDto
            {
                VolunteerID = Volunteer.VolunteerID,
                FirstName = Volunteer.FirstName,
                LastName = Volunteer.LastName,
                DepartmentID = Volunteer.DepartmentID,
                VolunteerHasPic = Volunteer.VolunteerHasPic,
                PicExtension = Volunteer.PicExtension

            };


            //pass along data as 200 status code OK response
            return Ok(VolunteerDto);
        }
Example #5
0
        public ActionResult ApproveConfirm(int id)
        {
            string url = "volunteerdata/findvolunteer/" + id;
            HttpResponseMessage res = client.GetAsync(url).Result;

            if (res.IsSuccessStatusCode)
            {
                VolunteerDto VolunteerDto = res.Content.ReadAsAsync <VolunteerDto>().Result;
                return(View(VolunteerDto));
            }
            return(RedirectToAction("Error"));
        }
        public ActionResult DeleteConfirm(int id)
        {
            string url = "volunteerdata/findvolunteer/" + id;
            HttpResponseMessage response = client.GetAsync(url).Result;

            if (response.IsSuccessStatusCode)
            {
                //Put data into volunteer data transfer object
                VolunteerDto SelectedVolunteer = response.Content.ReadAsAsync <VolunteerDto>().Result;
                return(View(SelectedVolunteer));
            }
            else
            {
                return(RedirectToAction("Error"));
            }
        }
Example #7
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);
        }
        public IHttpActionResult GetVolunteers()
        {
            List<Volunteer> Volunteers = db.Volunteers.ToList();
            List<VolunteerDto> VolunteerDtos = new List<VolunteerDto> { };


            foreach (var Volunteer in Volunteers)
            {
                VolunteerDto NewVolunteer = new VolunteerDto
                {
                    VolunteerID = Volunteer.VolunteerID,
                    FirstName = Volunteer.FirstName,
                    LastName = Volunteer.LastName,
                    VolunteerHasPic = Volunteer.VolunteerHasPic,
                    PicExtension = Volunteer.PicExtension,
                    DepartmentID = Volunteer.DepartmentID
                };
                VolunteerDtos.Add(NewVolunteer);
            }

            return Ok(VolunteerDtos);
        }
        public IHttpActionResult FindVolunteer(int id)
        {
            Volunteer Volunteer = db.volunteers.Find(id);

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

            VolunteerDto VolunteerDto = new VolunteerDto
            {
                volunteerId     = Volunteer.volunteerId,
                firstName       = Volunteer.firstName,
                lastName        = Volunteer.lastName,
                policeCheckPass = Volunteer.policeCheckPass,
                email           = Volunteer.email,
                phone           = Volunteer.phone,
                approved        = Volunteer.approved
            };

            return(Ok(VolunteerDto));
        }
        public IHttpActionResult GetVolunteers()
        {
            List <Volunteer>    Volunteers    = db.volunteers.ToList();
            List <VolunteerDto> VolunteerDtos = new List <VolunteerDto> {
            };

            foreach (var Volunteer in Volunteers)
            {
                VolunteerDto newVolunteer = new VolunteerDto
                {
                    volunteerId     = Volunteer.volunteerId,
                    firstName       = Volunteer.firstName,
                    lastName        = Volunteer.lastName,
                    policeCheckPass = Volunteer.policeCheckPass,
                    email           = Volunteer.email,
                    phone           = Volunteer.phone,
                    approved        = Volunteer.approved
                };
                VolunteerDtos.Add(newVolunteer);
            }

            return(Ok(VolunteerDtos));
        }