public ActionResult ProcessNewOrganization(NewOrganizationViewModel newOrganization) { if (!this.ModelState.IsValid) { return(View("RegisterNewOrganization", newOrganization)); } // If execution gets here, we have valid details. The first thing we will do is to create the organisation. // Let's build an organisation... Organization newOrg = new Organization(); newOrg.Verified = false; newOrg.OrganizationName = newOrganization.OrganizationName; newOrg.Location = newOrganization.Address; newOrg.Type = newOrganization.Type; // TODO POint of contact? // Get registering person to make them the organization admin Person person = GetCurrentVolunteer(); if (person == null) { throw new ArgumentException("Logged-in person not found or is an administrator."); } // Now pass the new organization out through the Organisation service so it can be persisted in the database. newOrg = OrganizationService.AddOrganization(newOrg, person.Id); Task.Run(() => { var routeValues = new RouteValueDictionary(); routeValues.Add("organizationId", newOrg.OrganizationId); var organizationVerificationLink = Url.Action("VerifyOrganization", "Organization", routeValues, Request.Url.Scheme); var body = string.Format( @"<p>Click on the following link to verify the new organization : <a href='{0}'>{0}</a> </p>", organizationVerificationLink); var message = new Message("CrisisCheckin - Verify your organization", body); MessageService.SendMessage(message, person, "CrisisCheckin"); }); // Send the verification email out to the user. return(View()); }
public ActionResult RegisterNewOrganization() { var person = VolunteerService.FindByUserId(WebSecurityWrapper.CurrentUserId); if (person == null) { throw new InvalidOperationException("A volunteer must be logged in to register a new organization."); } var model = new NewOrganizationViewModel() { Address = new Address(), OrganizationName = "", Type = OrganizationTypeEnum.Local }; return(View(model)); }
public ActionResult RegisterNewOrganization() { var person = VolunteerService.FindByUserId(WebSecurityWrapper.CurrentUserId); int personId = 0; if (person != null) { personId = person.Id; } var model = new NewOrganizationViewModel() { Address = new Address(), OrganizationName = "", Type = OrganizationTypeEnum.Local, UserIdRegisteringOrganization = personId }; return(View(model)); }