Esempio n. 1
0
        public async Task <ActionResult> SignUp(Models.VolunteerSignup model, Models.Volunteer volunteer)
        {
            try
            {
                volunteer.Email       = model.Email;
                volunteer.Name        = model.Name;
                volunteer.Password    = model.Password;
                volunteer.Mobile      = model.Mobile;
                volunteer.NID         = model.NID;
                volunteer.Designation = "member";
                volunteer.UserType    = "volunteer";

                var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));

                var a = await auth.CreateUserWithEmailAndPasswordAsync(model.Email, model.Password, model.Name, true);

                ModelState.AddModelError(string.Empty, "Please verify your email then login please.");
                CreateVolunteer(volunteer);
            }
            catch (Exception ex)
            {
                ModelState.AddModelError(string.Empty, ex.Message);
            }

            return(View());
        }
        public ActionResult AdminUnScheduleVolunteer(int volunteerID, int eventID)
        {
            ScheduleVolunteerDBEntities x = new ScheduleVolunteerDBEntities();

            x.unSchedule_Volunteer(volunteerID, eventID);

            EventDBEntities _Edb   = new EventDBEntities();
            var             events = _Edb.Events.ToList();

            Models.Event myEvent = (Models.Event)(events.Where(y => y.EventID == eventID).FirstOrDefault());

            VolunteersDBEntities _Vdb = new VolunteersDBEntities();
            var volunteers            = _Vdb.Volunteers.ToList();

            Models.Volunteer myVolunteer = (Models.Volunteer)(volunteers.Where(z => z.ID == volunteerID).FirstOrDefault());

            //notify volunteer of schedule change
            SmtpClient  client          = new SmtpClient();
            MailMessage notifyVolunteer = new MailMessage();

            notifyVolunteer.Subject = "You have been unscheduled from an event at the Challenged Champions Equestrian Center";
            notifyVolunteer.Body    = "This is an automated message informing you that an administrator has unscheduled you from the following event: "
                                      + myEvent.EventTitle + " on " + myEvent.EventDate.ToString("MM-dd-yyyy")
                                      + ". Please check the \"My Schedule\" portion of the volunteer website to review your schedule.";
            notifyVolunteer.To.Add(myVolunteer.Email);

            client.Send(notifyVolunteer);

            return(new EmptyResult());
        }
Esempio n. 3
0
        public void AddVolunteerToFirebase(Models.Volunteer volunteer)
        {
            firebaseClient = new FireSharp.FirebaseClient(firebaseConfig);
            var          data     = volunteer;
            PushResponse response = firebaseClient.Push("Volunteer/", data);

            data._id = response.Result.name;
            SetResponse setResponse = firebaseClient.Set("Volunteer/" + data._id, data);
        }
Esempio n. 4
0
 // database store
 public void CreateVolunteer(Models.Volunteer volunteer)
 {
     try
     {
         AddVolunteerToFirebase(volunteer);
         Console.WriteLine("Added Successfully");
     }
     catch (Exception ex)
     {
         ModelState.AddModelError(string.Empty, ex.Message);
         Console.WriteLine("exception from Create User: " + ex.Message);
     }
 }
        private void ApplyVolunteerData(Identity identity)
        {
            if (identity.Role == CustomIdentityRole.Volunteer || identity.Role == CustomIdentityRole.NGOAdmin)
            {
                Models.Volunteer volunteer = applicationDbContext.Volunteers.Find(identity.ID);

                if (volunteer.NGOID.HasValue)
                {
                    Models.NGO ngo = applicationDbContext.NGOs.Find(volunteer.NGOID);

                    identity.NGOID   = volunteer.NGOID.Value;
                    identity.NGOName = ngo.Name;
                }
            }
        }
Esempio n. 6
0
        public async Task <IActionResult> OnPostAsync(string returnUrl = null)
        {
            returnUrl = returnUrl ?? Url.Content("~/");
            if (ModelState.IsValid)
            {
                var user = new IdentityUser {
                    UserName = Input.Email, Email = Input.Email
                };
                var result = await _userManager.CreateAsync(user, Input.Password);

                if (result.Succeeded)
                {
                    _logger.LogInformation("User created a new account with password.");

                    Address address = new Address(Input.City, Input.Street, Input.BuildingNumber, Input.ApartmentNumber, Input.PostalCode);

                    AppUser appUser = null;
                    if (!string.IsNullOrEmpty(Input.PESEL))
                    {
                        appUser = new Models.Volunteer
                                  (
                            user.Id,
                            Input.FirstName,
                            Input.LastName,
                            Input.Email,
                            Input.PhoneNumber,
                            address,
                            Input.PESEL
                                  );
                        await _userManager.AddToRoleAsync(user, Roles.VolunteerRole);
                    }
                    else
                    {
                        appUser = new Models.Organizer
                                  (
                            user.Id,
                            Input.FirstName,
                            Input.LastName,
                            Input.Email,
                            Input.PhoneNumber,
                            address
                                  );
                        await _userManager.AddToRoleAsync(user, Roles.OrganizerRole);
                    }

                    _db.AppUsers.Add(appUser);
                    _db.SaveChanges();

                    var code = await _userManager.GenerateEmailConfirmationTokenAsync(user);

                    var callbackUrl = Url.Page(
                        "/Account/ConfirmEmail",
                        pageHandler: null,
                        values: new { userId = user.Id, code = code },
                        protocol: Request.Scheme);

                    await _emailSender.SendEmailAsync(Input.Email, "Confirm your email",
                                                      $"Please confirm your account by <a href='{HtmlEncoder.Default.Encode(callbackUrl)}'>clicking here</a>.");

                    await _signInManager.SignInAsync(user, isPersistent : false);

                    return(LocalRedirect(returnUrl));
                }
                foreach (var error in result.Errors)
                {
                    ModelState.AddModelError(string.Empty, error.Description);
                }
            }

            // If we got this far, something failed, redisplay form
            return(Page());
        }