public async Task <Contracts.ResultContract <bool> > AddOrganization([FromBody] OrganizationContract organization)
 {
     try
     {
         return(_organizationService.AddOrganization(organization));
     }
     catch (Exception)
     {
         return(new Contracts.ResultContract <bool>()
         {
             Code = -1, Msg = "服务异常"
         });
     }
 }
Esempio n. 2
0
        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 Organization AddOrganization(Organization organization)
 {
     return(organizationService.AddOrganization(organization));
 }