Ejemplo n.º 1
0
        public ActionResult AfterExternalLoginCallBack(string username, string email, string providerKey, string provider, string prfileurl, string fullname)
        {
            var cu = new ContextUser
            {
                OUser = new user
                {
                    Username = username,
                    Email    = email
                },
                EnumRole   = EnumUserRole.Volunteer,
                GoogleId   = provider == "Google" ? providerKey : null,
                LinkedInId = provider == "LinkedIn" ? providerKey : null,
                FullName   = fullname,
                ProfileUrl = prfileurl
            };


            FormsAuthentication.SetAuthCookie(username, false);
            var repository = new VolunteerRepository();
            volunteer_profile oVoluntee = null;

            Session["user"] = cu;
            if (provider == "Google")
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.GoogleSigninId == providerKey);
            }
            else if (provider == "user")
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.UserId == int.Parse(providerKey));
            }
            else
            {
                oVoluntee = repository.Get().FirstOrDefault(x => x.LinkedInSignInId == providerKey);
            }
            if (oVoluntee != null)
            {
                cu.OUser.Id     = oVoluntee.Id;
                Session["user"] = cu;
                if (oVoluntee.IsApprovedAtLevel1 != null && oVoluntee.IsApprovedAtLevel1.Value &&
                    oVoluntee.IsApprovedAtLevel2 != null && oVoluntee.IsApprovedAtLevel2.Value &&
                    oVoluntee.IsApprovedAtLevel3 != null && oVoluntee.IsApprovedAtLevel3.Value &&
                    !oVoluntee.OTAttendenceForVolunteer)
                {
                    return(RedirectToAction("Edit", "Supervisor", new { id = oVoluntee.RowGuid }));
                }
                if (oVoluntee.OTAttendenceForVolunteer)
                {
                    return(RedirectToAction("Index", "Session"));
                }
                return(RedirectToAction("VolunteerProfile", "Volunteer"));
            }
            return(RedirectToAction("VolunteerProfile", "Volunteer"));
        }
Ejemplo n.º 2
0
        public ActionResult Index(string status = "pending", int page = 1, Guid?archive = null)
        {
            IEnumerable <volunteer_profile> volunteers;
            var repository = new VolunteerRepository();

            var cu = Session["user"] as ContextUser;

            volunteers    = repository.Get(cu.EnumRole, status);
            ViewBag.Count = volunteers.Count();

            if (archive != null)
            {
                var volunteer = repository.GetbyGuid(archive.Value);
                volunteer.IsActive = volunteer.IsActive == null ? true : !volunteer.IsActive.Value;
                repository.Put(volunteer.Id, volunteer);
            }

            page = page > 0 ? page : 1;
            int pageSize = 0;

            pageSize = pageSize > 0 ? pageSize : 10;

            return(View(volunteers.ToPagedList(page, pageSize)));
        }
Ejemplo n.º 3
0
        public ActionResult VolunteerProfile()
        {
            volunteer_profile oVolunteer = null;
            var cu         = Session["user"] as ContextUser;
            var repository = new VolunteerRepository();

            if (cu != null)
            {
                if (cu.OUser.Id != 0)
                {
                    oVolunteer = repository.Get(cu.OUser.Id);
                }
                if (oVolunteer == null)
                {
                    oVolunteer = repository.GetByUserId(cu.OUser.Id);
                }
                if (oVolunteer == null)
                {
                    oVolunteer = repository.GetByLinkedInId(cu.LinkedInId);
                }
                if (oVolunteer == null)
                {
                    oVolunteer = repository.GetByGoogleId(cu.GoogleId);
                }
                if (oVolunteer == null)
                {
                    oVolunteer = new volunteer_profile();
                    oVolunteer.VolunteerEmail = cu.OUser.Email;
                    oVolunteer.VolunteerName  = cu.FullName;
                    oVolunteer.LinkedIn       = cu.ProfileUrl;
                }
                oVolunteer.GoogleSigninId   = cu.GoogleId;
                oVolunteer.LinkedInSignInId = cu.LinkedInId;
            }
            else
            {
                oVolunteer = new volunteer_profile();
            }
            ViewBag.genderdd = new List <SelectListItem>
            {
                new SelectListItem {
                    Selected = true, Text = General.Male, Value = "Male"
                },
                new SelectListItem {
                    Selected = false, Text = General.Female, Value = "Female"
                }
            };
            var cities = new CityRepository().Get().Distinct().Select(x =>
                                                                      new SelectListItem {
                Text = x.City + " (" + x.City_ar + ")", Value = x.City + "", Selected = x.City == "Jeddah"
            }).ToList();

            ViewBag.citiesdd = cities;
            var distict = new CityRepository().Get().GroupBy(x => x.Region).Select(x => x.First()).Select(x =>
                                                                                                          new SelectListItem {
                Text = x.Region + " (" + x.Region_ar + ")", Value = x.Region + ""
            }).ToList();

            ViewBag.distictdd      = distict;
            oVolunteer.DateOfBirth = DateTime.Now;
            if (oVolunteer.Id == 0)
            {
                oVolunteer.VolExp = "";
            }
            else
            {
                oVolunteer.VolExp = !string.IsNullOrEmpty(oVolunteer.VolunteerExperince1) ? "Yes" : "No";
            }
            oVolunteer.SelectedExp = !string.IsNullOrEmpty(oVolunteer.VolunteerExperince1) ? oVolunteer.VolunteerExperince1.Split(',') : new string[] { };
            return(View(oVolunteer));
        }