Esempio n. 1
0
        public ActionResult AddVolunteer(OrganizationHomeViewModel model)
        {
            ModelState.RemoveErrorsExcept("OrganizationId,AddVolunteerId");
            if (!ModelState.IsValid)
            {
                return(View("Home", CreateHomeViewModel(model)));
            }

            try
            {
                ConfirmAdminAccess(model.OrganizationId);
                VolunteerService.AddVolunteerToOrganization(model.OrganizationId, model.AddVolunteerId);

                return(Redirect("Home/" + model.OrganizationId));
            }
            catch (InvalidOperationException ex)
            {
                ModelState.AddModelError("", ex.Message);
            }

            return(View("Home", CreateHomeViewModel(model.OrganizationId)));
        }