public IActionResult Volunteer(VolunteerViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!volunteerRepository.CheckUniqueEmail(viewModel.Email))
            {
                volunteerRepository.Add(new VolunteerModel()
                {
                    VolunteerId = viewModel.VolunteerId,
                    FirstName   = viewModel.FirstName,
                    LastName    = viewModel.LastName,
                    Email       = viewModel.Email,
                    Age         = viewModel.Age,
                    Description = viewModel.Description
                });

                ViewBag.message = "Your registration was successful!";
            }
            else
            {
                ViewBag.message = "You already used this email to submit this form!";
            }

            return(View(viewModel));
        }
Exemplo n.º 2
0
        public RedirectToActionResult Create(Volunteer newVol, string submit)
        {
            switch (submit)
            {
            case "Create":
                _volunteerRepository.Add(newVol);
                break;

            case "Cancel":
                break;
            }

            return(RedirectToAction("ManageVolunteers"));
        }
Exemplo n.º 3
0
        public IHttpActionResult Register(RegisterRequest register)
        {
            var volunteer = new Volunteer
            {
                FirstName    = register.FirstName,
                LastName     = register.LastName,
                Mobile       = register.Mobile,
                Email        = register.Email,
                PostCode     = register.PostCode,
                PasswordHash = register.PasswordHash,
                Availability = false
            };
            var volunteerWithId = _volunteerRepository.Add(volunteer);

            return(Ok(volunteerWithId));
        }
Exemplo n.º 4
0
 public Volunteer Add(Volunteer volunteer)
 {
     return(_volunteerRepository.Add(volunteer));
 }
Exemplo n.º 5
0
 public void Add(Volunteer volunteer)
 {
     _volunteerRepository.Add(volunteer);
 }