Ejemplo n.º 1
0
 public void Delete(Volunteer volunteer)
 {
     foreach (var volunteerJobRole in _dataContext.VolunteerJobRoles.Where(vjr => vjr.VolunteerId == volunteer.Id))
     {
         _dataContext.VolunteerJobRoles.Remove(volunteerJobRole);
     }
     foreach (var volunteerTechnology in _dataContext.VolunteerTechnologies.Where(vt => vt.VolunteerId == volunteer.Id))
     {
         _dataContext.VolunteerTechnologies.Remove(volunteerTechnology);
     }
     _dataContext.Volunteers.Remove(volunteer);
     _dataContext.SaveChanges();
 }
Ejemplo n.º 2
0
 public static LeiFeng CreateLeiFeng(string type)
 {
     LeiFeng result = null;
     switch (type)
     {
         case "学雷锋的大学生":
             result = new Undergraduate();
             break;
         case "社区志愿者":
             result = new Volunteer();
             break;
         default:
             break;
     }
     return result;
 }
Ejemplo n.º 3
0
        public ActionResult Apply(Volunteer volunteer)
        {
            if (ModelState.IsValid)
            {
                if(SendEmails(volunteer))
                {
                    ViewBag.Name = volunteer.Name;
                    ViewBag.EmailAddress = volunteer.EmailAddress;
                    ViewBag.Phone = volunteer.Phone;

                    return View("ApplicationReceived");
                }
            }

            ModelState.AddModelError("", "Something went wrong while trying to submit your volunteer application. " +
                                         "Please fix any errors below, if any. Otherwise, please try again, or email " +
                                         "us your intent to apply to become a volunteer for AWIC at " +
                                         System.Configuration.ConfigurationManager.AppSettings["OrganisationEmailAddress"] + ". ");

            return View(volunteer);
        }
Ejemplo n.º 4
0
        private bool SendEmails(Volunteer volunteer)
        {
            try
            {
                AWICEmailHelper.SendVolunteerApplicationEmail(volunteer);
            }
            catch (Exception e)
            {
                return false;
            }

            try
            {
                AWICEmailHelper.SendVolunteerApplicationReceivedEmail(volunteer);
            }
            catch (Exception e)
            {
                // No need to do anything here, since failure to send an email to the
                // volunteer does not come in the way of his/her application processs
            }

            return true;
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            MemberCollection members = MemberCollection.Instance;

            Member m1 = new Member("Andreas", "Istedgade 25, st. tv.", 27, 500);
            Member m2 = new Member("Per", "Snevej 1", 55, 500);
            Member m3 = new Member("Lars", "Fasanvej", 45, 500);

            Volunteer v1 = new Volunteer("Sofie", "Markvej 12", 22, 500, 250);
            Volunteer v2 = new Volunteer("Lise", "Hestemad 99", 34, 500, 90);
            Volunteer v3 = new Volunteer("Lars", "Ostevej 44", 33, 500, 100);

            Junior j1 = new Junior("Martin", "Flisevej 22", 17, 500, "Mor");
            Junior j2 = new Junior("Mads", "Markvej 1", 12, 500, "Far");
            Junior j3 = new Junior("Mikael", "Hansgade 88", 18, 500, "Bedste");

            members.AddMember(m1);
            members.AddMember(m2);
            members.AddMember(m3);

            members.AddMember(v1);
            Console.WriteLine(v1.GetFee());
            members.AddMember(v2);
            Console.WriteLine(v2.GetFee());
            members.AddMember(v3);
            Console.WriteLine(v3.GetFee());

            members.AddMember(j1);
            Console.WriteLine(j1.GetFee());
            members.AddMember(j2);
            Console.WriteLine(j2.GetFee());
            members.AddMember(j3);
            Console.WriteLine(j3.GetFee());

            Console.WriteLine("Total: " + members.GetTotalFee());
            Console.ReadLine();
        }
Ejemplo n.º 6
0
 public ActionResult SetGroupLeader(SetLeaderModel GroupLeader, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         Volunteer vol = db.Volunteers.Find(GroupLeader.LeaderId);
         if (vol == null)
         {
             return(Redirect(returnUrl));
         }
         var grp = vol.Group;
         if (grp.Leader != null)
         {
             if (Roles.GetRolesForUser(grp.Leader.UserName).Contains(LWSFRoles.groupLeader))
             {
                 Roles.RemoveUserFromRole(grp.Leader.UserName, LWSFRoles.groupLeader);
             }
         }
         grp.Leader     = vol;
         vol.AdminGroup = grp;
         db.SaveChanges();
         Roles.AddUserToRole(vol.UserName, LWSFRoles.groupLeader);
     }
     return(Redirect(returnUrl));
 }
Ejemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="locationId"></param>
        /// <param name="userName"></param>
        /// <returns></returns>
        //[HttpGet]
        public ActionResult VolunteerClockIn(int locationId, string userName)
        {
            Volunteer volunteer = volunteerInfoRepository.GetVolunteer(userName);
            Location  location  = lookUpRepository.GetLocationById((int)locationId);

            if (volunteer != null && volunteer.Id > 0)
            {
                VolunteerProfile profile =
                    volunteerInfoRepository.GetLastProfileInfo(volunteer.Id);
                VolunteerTimeClock clockInfo = volunteerInfoRepository.GetClockedInInfo(volunteer);

                //todo move to a view model?
                ViewBag.isClockedIn = (clockInfo != null); // clocked in
                ViewBag.Case        = profile != null ? profile.CaseNumber : "NA";

                TempData["VolunteerInfo"] = volunteer;
                TempData["Location"]      = location;

                VolunteerClockInViewModel vm = new VolunteerClockInViewModel();
                vm.Volunteer    = volunteer;
                vm.LocationId   = (int)location.Id;
                vm.LocationName = location.Name;
                VolunteerPhoto photo = volunteerInfoRepository.GetLastPhotoInfo(volunteer);
                if (photo != null)
                {
                    vm.DefaultPhotoPath = volunteerInfoRepository.GetLastPhotoInfo(volunteer).Path;
                }

                //dispose now, new context will be created in next request
                volunteerInfoRepository.Dispose();

                return(View(vm));
            }

            return(RedirectToAction("VolunteerLookUp", "VolunteerClockTime", new { locationId = location.Id }));
        }
Ejemplo n.º 8
0
 public void Save(Volunteer volunteer)
 {
     if (volunteer.Id == Guid.Empty)
     {
         _context.Volunteers.Add(volunteer);
     }
     else
     {
         Volunteer dbEntry = _context.Volunteers.FirstOrDefault(v => v.Id == volunteer.Id);
         if (dbEntry != null)
         {
             dbEntry.FirstName             = volunteer.FirstName;
             dbEntry.LastName              = volunteer.LastName;
             dbEntry.Username              = volunteer.Username;
             dbEntry.Password              = volunteer.Password;
             dbEntry.Centers               = volunteer.Centers;
             dbEntry.Skills                = volunteer.Skills;
             dbEntry.AvailableTimes        = volunteer.AvailableTimes;
             dbEntry.Address               = volunteer.Address;
             dbEntry.PhoneNumbers          = volunteer.PhoneNumbers;
             dbEntry.Email                 = volunteer.Email;
             dbEntry.EducationalBackground = volunteer.EducationalBackground;
             dbEntry.CurrentLicenses       = volunteer.CurrentLicenses;
             dbEntry.EmerContactName       = volunteer.EmerContactName;
             dbEntry.EmerPhoneNum          = volunteer.EmerPhoneNum;
             dbEntry.EmerAddress           = volunteer.EmerAddress;
             dbEntry.EmerEmail             = volunteer.EmerEmail;
             dbEntry.IsApproved            = volunteer.IsApproved;
             dbEntry.IsDrivLicense         = volunteer.IsDrivLicense;
             dbEntry.IsSocSec              = dbEntry.IsSocSec;
             dbEntry.IsPending             = dbEntry.IsPending;
             dbEntry.IsInactive            = dbEntry.IsInactive;
         }
     }
     _context.SaveChanges();
 }
Ejemplo n.º 9
0
        public async Task UpdateVolunteerAsync(Volunteer updatedVolunteer)
        {
            if (string.IsNullOrEmpty(updatedVolunteer.Organization.Id))
            {
                throw new InvalidOperationException($"Volunteer {updatedVolunteer.Id} is not associated with an organization");
            }

            var volunteer = mapper.Map <Models.Db.Volunteer>(updatedVolunteer);
            var orgId     = volunteer.OrganizationId.Value;

            if (volunteer.IsPrimaryContact ?? false)
            {
                await SetVolunteerAsPrimaryContact(volunteer, orgId);

                volunteer.IsPrimaryContact = true;
            }
            else
            {
                volunteer.IsPrimaryContact = false;
            }
            db.Volunteers.Update(volunteer);

            await db.SaveChangesAsync();
        }
Ejemplo n.º 10
0
        public IHttpActionResult GetLogin(string id, string id2)
        {
            Custom_Validation cval = new Custom_Validation();

            cval.Volunteers = db.Volunteers.ToList();
            cval.Users      = db.Users.ToList();
            cval.Drivers    = db.Drivers.ToList();

            var obj = cval.Login_Validation(id, id2);

            if (obj is Volunteer)
            {
                Volunteer     vol     = obj as Volunteer;
                DTO_Volunteer dto_vol = new DTO_Volunteer();
                vol.ConvertToDTO(dto_vol);
                return(Ok(new { obj = dto_vol, type = "volunteer" }));
            }
            else if (obj is User)
            {
                User     vol      = obj as User;
                DTO_User dto_user = new DTO_User();
                vol.ConvertToDTO(dto_user);
                return(Ok(new { obj = dto_user, type = "user" }));
            }
            else if (obj is Driver)
            {
                Driver     dri     = obj as Driver;
                DTO_Driver dto_dri = new DTO_Driver();
                dri.ConvertToDTO(dto_dri);
                return(Ok(new { obj = dto_dri, type = "driver" }));
            }
            else
            {
                return(Ok("Error"));
            }
        }
Ejemplo n.º 11
0
        public async Task <IActionResult> Edit(Guid id)
        {
            NGO ngo = applicationDbContext.NGOs.Find(id);

            ngo.NGOStatus = NGOStatus.Verified;

            ApplicationUser user = await userManager.FindByIdAsync(ngo.CreatedByID.ToString());

            await userManager.RemoveFromRoleAsync(user, Framework.Identity.CustomIdentityRole.Guest);

            await userManager.AddToRoleAsync(user, Framework.Identity.CustomIdentityRole.NGOAdmin);

            Volunteer volunteer = new Volunteer();

            volunteer.ID              = ngo.CreatedByID;
            volunteer.NGOID           = ngo.ID;
            volunteer.VolunteerStatus = VolunteerStatus.Verified;

            applicationDbContext.Volunteers.Add(volunteer);

            await applicationDbContext.SaveChangesAsync();

            return(RedirectToAction(nameof(Index)));
        }
Ejemplo n.º 12
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            if (textBoxUsername.Text == "" || textBoxPassword.Text == "")
            {
                MessageBox.Show("Please provide Username and Password");
                return;
            }

            string    user      = textBoxUsername.Text;
            string    pass      = textBoxPassword.Text;
            Volunteer volunteer = this.controller.login(user, pass);

            if (volunteer != null)
            {
                MessageBox.Show("Login Successful!");
                this.Hide();
                FormMain fm = new FormMain(controller);
                fm.Show();
            }
            else
            {
                MessageBox.Show("Login Failed!");
            }
        }
Ejemplo n.º 13
0
        public async Task <bool> postVolunteer(string name, string email, string password, string contact, string postalcode, Subzone zone, string assignedzone)
        {
            var ap = new FirebaseAuthProvider(new Firebase.Auth.FirebaseConfig("AIzaSyBjdJIn1k3ksbbZAgY-kQIwUXbD0Zo_q8w"));
            FirebaseAuthLink res;

            try
            {
                res = await ap.CreateUserWithEmailAndPasswordAsync(email, password);      //Attemps to create user with given email & password
            }
            catch
            {
                return(false);
            }
            Volunteer volunteer = new Volunteer();

            volunteer.Name          = name;
            volunteer.Email         = email;
            volunteer.Password      = password;
            volunteer.Contact       = Convert.ToInt32(contact);
            volunteer.PostalCode    = postalcode;
            volunteer.ZoneID        = zone.Name;
            volunteer.RegionCode    = zone.REGION_C;
            volunteer.AssignedZones = assignedzone;
            await firebaseClient
            .Child("volunteer")
            .Child(res.User.LocalId)
            .PutAsync(volunteer);

            await firebaseClient
            .Child("authroles")                                          // Places UserID in the authroles section
            .PatchAsync("{\"" + res.User.LocalId + "\":\"volunteer\"}"); //Patching in JSON format - "USERID:elderly"

            await PostLog("Created Volunteer");

            return(true);
        }
Ejemplo n.º 14
0
    public List <Message> getMessages(string displayName)
    {
        //displayName = displayName.Replace("'", "''");

        Volunteer v = new Volunteer();

        v.DisplayName = displayName;
        Volunteer      volunteer = v.getVolunteer();
        int            ID        = volunteer.Id;
        string         query     = "select * from [Messages] where UserID= '" + ID + "'";
        List <Message> list      = new List <Message>();
        DbService      db        = new DbService();
        DataSet        ds        = db.GetDataSetByQuery(query);

        foreach (DataRow dr in ds.Tables[0].Rows)
        {
            Message m = new Message();
            m.msgID    = int.Parse(dr["MsgID"].ToString());
            m.parentID = int.Parse(dr["ParentID"].ToString());
            m.type     = dr["Type"].ToString();
            m.title    = dr["Title"].ToString();

            m.msgContent = dr["MsgContent"].ToString();
            m.ridePatID  = int.Parse(dr["RidePatID"].ToString());
            m.dateTime   = dr["DateTime"].ToString();
            m.userID     = int.Parse(dr["UserID"].ToString());
            m.userNotes  = dr["UserNotes"].ToString();
            m.isPush     = Convert.ToBoolean(dr["IsPush"].ToString());
            m.isMail     = Convert.ToBoolean(dr["IsMail"].ToString());
            m.isWhatsapp = Convert.ToBoolean(dr["IsWhatsapp"].ToString());
            m.Sender     = dr["Sender"].ToString();
            list.Add(m);
        }

        return(list);
    }
        public async Task <ActionResult> ForgotPassword(ForgotPasswordViewModel model)
        {
            if (ModelState.IsValid)
            {
                using (VolunteersDBEntities db = new VolunteersDBEntities())
                {
                    if (EmailValidation(model.Email))
                    {
                        Volunteer forgetUser = db.Volunteers.FirstOrDefault(u => u.Email == model.Email);
                        if (forgetUser != null)
                        {
                            forgetUser.GUID = Guid.NewGuid().ToString();
                            db.SaveChanges();
                            SendEmail(forgetUser.Email, "Reset Password", "Your reset password link is http://" + Request.Url.Authority + "/Account/ResetPassword?code=" + forgetUser.GUID);
                            return(View("ForgotPasswordConfirmation"));
                        }
                    }
                }
            }
            string message = "invalid email entered. Please try again.";

            ViewBag.Message = message;
            return(View(model));
        }
Ejemplo n.º 16
0
        public void TestCompareTopics()
        {
            //Give each topic 3 topics of which 2 are the same across both.
            Topic Topics1 = new Topic();

            Topics1.QuickSetProperties(true, true, false, true, false, false);

            Topic Topics2 = new Topic();

            Topics2.Culture   = true;
            Topics2.Nature    = true;
            Topics2.Political = true;

            Assert.AreEqual(Topics2.Nature, Topics1.Nature);
            Assert.AreNotEqual(Topics2.Political, Topics1.Political);

            Volunteer v = new Volunteer();

            v.VolunteerPreferences = Topics2;
            int output   = v.VolunteerPreferences.CompareTopics(Topics1);
            int expected = 2;

            Assert.AreEqual(expected, output);
        }
Ejemplo n.º 17
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            //Volunteer = await _context.Volunteer.FirstOrDefaultAsync(m => m.VolunteerID == id);
            Volunteer = await _context.Volunteer
                        .Include(v => v.Address)
                        .Include(v => v.AditionalInfo)
                        .Include(v => v.ContactInformation)
                        .Include(v => v.Contract)
                        .Include(v => v.Workschedule)
                        .ThenInclude(w => w.Comments)
                        .AsNoTracking()
                        .FirstOrDefaultAsync(m => m.VolunteerID == id);

            if (Volunteer == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Ejemplo n.º 18
0
        public ResultObject UpdateVolunteer(Volunteer volunteer, int currentUserId)
        {
            var validationResult = _validation.ValidateVolunteerToUpdate(volunteer, currentUserId);

            if (validationResult.Success)
            {
                var response = new ResultObject();

                var updateVolunteerSuccess = _volunteerRepository.UpdateVolunteer(volunteer);

                if (updateVolunteerSuccess)
                {
                    response.Success = true;
                    response.Message = "10026";
                    return(response);
                }

                response.Success = false;
                response.Errors.Add("10027");
                return(response);
            }

            return(validationResult);
        }
Ejemplo n.º 19
0
        public bool AddVolunteer(Volunteer volunteer)
        {
            try
            {
                _applicationdbcontext.Volunteers.Add(new Volunteer()
                {
                    VolunteerName     = volunteer.VolunteerName,
                    Location          = volunteer.Location,
                    VolunteerOutletId = volunteer.VolunteerOutletId,
                });
                _applicationdbcontext.SaveChanges();
                var updationOfNoOfVolunteers = _applicationdbcontext.Outlets.FirstOrDefault(p => p.OutletId == volunteer.VolunteerOutletId);
                updationOfNoOfVolunteers.NoOfVolunteers++;
                _applicationdbcontext.Outlets.Update(updationOfNoOfVolunteers);

                _applicationdbcontext.SaveChanges();

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
Ejemplo n.º 20
0
        public ActionResult Users_Update([DataSourceRequest] DataSourceRequest request, Volunteer volunteer)
        {
            if (this.ModelState.IsValid)
            {
                var entity = new Volunteer
                {
                    Id                   = volunteer.Id,
                    UserName             = volunteer.UserName,
                    Description          = volunteer.Description,
                    Image                = volunteer.Image,
                    CreatedOn            = volunteer.CreatedOn,
                    ModifiedOn           = volunteer.ModifiedOn,
                    IsDeleted            = volunteer.IsDeleted,
                    DeletedOn            = volunteer.DeletedOn,
                    Email                = volunteer.Email,
                    EmailConfirmed       = volunteer.EmailConfirmed,
                    PasswordHash         = volunteer.PasswordHash,
                    SecurityStamp        = volunteer.SecurityStamp,
                    PhoneNumber          = volunteer.PhoneNumber,
                    PhoneNumberConfirmed = volunteer.PhoneNumberConfirmed,
                    TwoFactorEnabled     = volunteer.TwoFactorEnabled,
                    LockoutEndDateUtc    = volunteer.LockoutEndDateUtc,
                    LockoutEnabled       = volunteer.LockoutEnabled,
                    AccessFailedCount    = volunteer.AccessFailedCount,
                    FirstName            = volunteer.FirstName,
                    LastName             = volunteer.LastName,
                    Age                  = volunteer.Age,
                };

                this.db.Users.Attach(entity);
                this.db.Entry(entity).State = EntityState.Modified;
                this.db.SaveChanges();
            }

            return(this.Json(new[] { volunteer }.ToDataSourceResult(request, this.ModelState)));
        }
Ejemplo n.º 21
0
        public void ApproveVolunteer(int Id)
        {
            using (ApplicationDbContext db = new ApplicationDbContext())
            {
                Volunteer him = db.Volunteers
                                .Include("Pet")
                                .Include("Detail")
                                .Where(x => x.Id == Id)
                                .FirstOrDefault();

                him.Status = Status.Approved;

                if (him.Type == VolunteerType.Adopter)
                {
                    Pet adopted = db.Pets.Find(him.Pet.Id);
                    adopted.Adopted = true;
                }
                else
                {
                    Pet      goingWalking = db.Pets.Find(him.Pet.Id);
                    Schedule schedule     = new Schedule();

                    schedule.Pet         = goingWalking;
                    schedule.PetId       = goingWalking.Id;
                    schedule.Volunteer   = him;
                    schedule.VolunteerId = him.Id;
                    schedule.StartTime   = him.Detail.StartDate;
                    schedule.EndTime     = him.Detail.EndDate;

                    schedule.calcAvailability();
                    db.Schedules.Add(schedule);
                }

                db.SaveChanges();
            }
        }
Ejemplo n.º 22
0
 public VolunteerResult DeleteVolunteer(Volunteer a)
 {
     if (a != null)
     {
         int                    deletedVolunteerStuNum = a.StudentNum;
         string                 deletedVolunteerName   = a.Name;
         var                    volunteer = FindVolunteer(a.StudentNum);
         List <LogRecord>       loglist   = logger.FindLogRecordByTargetVolunteer(volunteer).ToList();
         List <BlackListRecord> blacklist = database.BlackListRecords.Where(b => b.Volunteer.UID == volunteer.UID).ToList();
         //foreach (var log in loglist)
         //{
         //    log.TargetVolunteer = null;
         //}
         //Save();//等待被注释
         database.Volunteers.Remove(volunteer);
         Save();
         bool logresult = VolunteerOperationSucceeded(string.Format("删除学号:{0},姓名:{1}的志愿者条目.", deletedVolunteerStuNum, deletedVolunteerName), null, LogType.DeleteVolunteer);
         return(VolunteerResult.Success());
     }
     else
     {
         return(VolunteerResult.Error(VolunteerResult.DeleteVolunteerErrorEnum.NonExistingVolunteer));
     }
 }
Ejemplo n.º 23
0
 public VolunteerResult AddVolunteer(Volunteer v)
 {
     if (v == null)
     {
         return(VolunteerResult.Error(VolunteerResult.AddVolunteerErrorEnum.NullVolunteerObject));
     }
     if (v.StudentNum == 0)
     {
         return(VolunteerResult.Error(VolunteerResult.AddVolunteerErrorEnum.EmptyId));
     }
     if (database.Volunteers.Where(o => o.StudentNum == v.StudentNum).Count() != 0)
     {
         return(VolunteerResult.Error(VolunteerResult.AddVolunteerErrorEnum.SameIdVolunteerExisted, v.StudentNum));
     }
     else
     {
         int stunum = v.StudentNum;
         v.Mobile           = v.Mobile == DEFAULTSTRING ? DEFAULTSTRING : v.Mobile;
         v.Room             = v.Room == DEFAULTSTRING ? DEFAULTSTRING : v.Room;
         v.Name             = v.Name == DEFAULTSTRING ? DEFAULTSTRING : v.Name;
         v.Class            = v.Class == DEFAULTSTRING ? DEFAULTSTRING : v.Class;
         v.Email            = v.Email == DEFAULTSTRING ? DEFAULTSTRING : v.Email; //加入几个列表的初始化.
         v.BlackListRecords = new List <BlackListRecord>();
         v.CreditRecords    = new List <CreditRecord>();
         v.ProjectCount     = 0;
         v.Project          = new List <Project>();
         v.Skill            = v.Skill;
         v.Score            = new Volunteer.VScore();
         v.TargetedBy       = new List <LogRecord>();
         database.Volunteers.Add(v);
         Save();
         Volunteer target    = FindVolunteer(stunum);
         bool      logresult = VolunteerOperationSucceeded(string.Format("已添加学号:[{0}],姓名:[{1}] 的志愿者条目进入数据库.", target.StudentNum, target.Name), target, LogType.EditContact, true);
         return(VolunteerResult.Success());
     }
 }
Ejemplo n.º 24
0
        public ActionResult NewStudentList()
        {
            Volunteer currVol = GetCurrentVolunteer();
            List <NewStudentViewModel> studList = new List <NewStudentViewModel>();

            if (currVol.Organization.ModelType == OrgModelType.IntGroupless)
            {
                studList = NewStudentListOps._GetOrgImcompletedNewStudents(currVol.OrganizationId);
            }
            else if (currVol.GroupId != null)
            {
                studList = NewStudentListOps._GetGrpUnassignedNewStudents(currVol.GroupId.Value);
            }

            if (NewStudentListOps.IsOrgFacss(currVol.Organization.Name))
            {
                foreach (var stud in studList)
                {
                    stud.CnName = stud.Id.ToString();
                }
            }

            return(View(studList));
        }
Ejemplo n.º 25
0
        public static void SendVolunteerApplicationReceivedEmail(Volunteer volunteer)
        {
            UrlHelper urlHelper = new UrlHelper(HttpContext.Current.Request.RequestContext);
            string path = urlHelper.Action("Contact", "Home");
            Uri fullURL = new Uri(HttpContext.Current.Request.Url, path);

            string Subject = "Your Volunteer Application for AWIC";

            string HTMLBody =
                "<p>Hi " + volunteer.Name + ", </p>" +
                "<p>Thank you for your interest in volunteering with us! </p>" +
                "<p>We have received your application and will begin reviewing it soon. Once we've reviewed your " +
                    "application, we'll let you know via email (at " + volunteer.EmailAddress + "), or phone (at " +
                    volunteer.Phone + ") about whether or not we want you to come in for an interview. </p>" +
                "<p>If you have any questions or concerns about anything until then, feel free to reply back with your " +
                    "message and we'll be glad to address it. You can also call Elmira Mammadova at (416) 499-4144 with " +
                    "your message, who will be more than glad to help you. </p>" +
                "<br />" +
                "<p>Sincerely, </p>" +
                "<p>The AWIC Team</p>" +
                "<br />" +
                "<p>PS You can find our general contact information <a href=\"" + fullURL + "\">here</a>. </p>";

            SendEmail(volunteer.EmailAddress, Subject, HTMLBody);
        }
Ejemplo n.º 26
0
        private IEnumerable<VolunteerTask> FormatEventTasks(ICollection<Services.Task> eventTasks)
        {
            var tasks = new List<VolunteerTask>(eventTasks.Count);

            VolunteerTask vt;
            foreach (var eventTask in eventTasks)
            {
                vt = new VolunteerTask
                         {
                             Id = eventTask.Id,
                             Description = eventTask.Description,
                             StartTime = eventTask.StartTime,
                             EndTime = eventTask.EndTime,
                             Capacity = eventTask.Capacity,
                             Volunteers = new List<Volunteer>()
                         };

                tasks.Add(vt);

                Volunteer v;
                foreach (var assignee in eventTask.Assignees)
                {
                    v = new Volunteer
                            {
                                FirstName = assignee.FirstName,
                                LastName = assignee.LastName,
                                Email = assignee.Email,
                                ID = assignee.ID,
                                ImageUrl =
                                    (String.IsNullOrEmpty(assignee.ImageUrl)
                                         ? CONST_DEFAULT_ICON_URL
                                         : assignee.ImageUrl)
                            };
                    vt.Volunteers.Add(v);
                }
            }
            return tasks;
        }
Ejemplo n.º 27
0
 //volunteer methods
 public Task <int> AddToVolunteer(Volunteer obj)
 {
     return(_database.InsertAsync(obj));
 }
Ejemplo n.º 28
0
        public IHttpActionResult PostLogin(Login model)
        {
            //验证Android手机终端
            IEnumerable <string> headerUuid = null;

            ActionContext.Request.Headers.TryGetValues("uuid", out headerUuid);
            if (headerUuid == null)
            {
                return(BadRequest("请从Android手机操作"));
            }
            string uuid = null;

            if (headerUuid != null)
            {
                uuid = headerUuid.ToList()[0];
            }
            //验证数据
            if (model == null)
            {
                return(BadRequest("请填写登录信息"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.First(s => s.Errors.Count > 0).Errors[0].ErrorMessage));
            }
            Volunteer volunteer = db.Volunteers.FirstOrDefault(s => s.MobileNumber == model.MobileNumber && s.Status != EnumUserStatus.注销); //应为0个或1个

            //验证是否已注册
            if (volunteer == null)
            {
                return(BadRequest("该手机号码未注册"));
            }
            //验证账户是否锁定
            if (volunteer.Status == EnumUserStatus.密码输入错误临时锁定)
            {
                if (volunteer.LockoutEndTime < DateTime.Now)
                {
                    volunteer.Status           = EnumUserStatus.正常;
                    volunteer.LockoutStartTime = null;
                    volunteer.LockoutDuration  = 0;
                    db.SaveChanges();
                }
                else
                {
                    return(BadRequest("账户被锁定"));
                }
            }
            //验证密码
            if (volunteer.Password != SecurityHelper.MD5Hash(model.PassWord))
            {
                return(BadRequest("密码不正确"));
            }
            //更新uuid
            if (uuid != null)
            {
                volunteer.Uuid = uuid;
            }

            VolunteerToken volunteerToken = db.VolunteerTokens.FirstOrDefault(s => s.VolunteerId == volunteer.Id);
            DateTime       now            = DateTime.UtcNow;
            string         token          = SecurityHelper.MD5Hash(volunteer.Id.ToString() + now.ToString() + Guid.NewGuid().ToString());

            if (volunteerToken == null)
            {
                volunteerToken = new VolunteerToken
                {
                    VolunteerId = volunteer.Id,
                    CreateTime  = now,
                    ActiveTime  = now,
                    Token       = token,
                    Validity    = 30
                };
                try
                {
                    db.VolunteerTokens.Add(volunteerToken);
                    db.Entry(volunteerToken).State = EntityState.Added;
                    db.SaveChanges();
                }
                catch
                {
                    db.Entry(volunteerToken).State = EntityState.Unchanged;
                    return(BadRequest("操作发生错误"));
                }
            }
            else
            {
                volunteerToken.ActiveTime      = now;
                volunteerToken.Token           = token;
                volunteerToken.Validity        = 30;
                db.Entry(volunteerToken).State = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch
                {
                    db.Entry(volunteerToken).State = EntityState.Unchanged;
                    return(BadRequest("操作发生错误"));
                }
            }
            return(Ok(new
            {
                Token = token,
                Volunteer = VolunteerService.FormatUser(volunteer)
            }));
        }
Ejemplo n.º 29
0
        public IHttpActionResult PostSendRegisterCaptcha(GetCaptcha model)
        {
            //验证数据
            if (model == null)
            {
                return(BadRequest("请输入手机号码"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.First(s => s.Errors.Count > 0).Errors[0].ErrorMessage));
            }

            Volunteer volunteer = db.Volunteers.FirstOrDefault(s => s.MobileNumber == model.MobileNumber && s.Status != EnumUserStatus.注销);

            //生成验证码
            string code = new Random().Next(100000, 999999).ToString();

#if DEBUG
            code = "666666";
            Thread.Sleep(2000);
#endif
            //存储手机号码、验证码等信息到数据库
            //1.新手机号码
            if (volunteer == null)
            {
                DateTime now = DateTime.Now;
                volunteer = new Volunteer
                {
                    Id                    = Guid.NewGuid(),
                    MobileNumber          = model.MobileNumber,
                    SmsCaptcha            = code,
                    SmsCaptchaUsedFor     = EnumCaptchaUsedFor.志愿者注册,
                    SmsCaptchaExpiredTime = now.AddMinutes(30),
                    RegisterTime          = now
                };
                try
                {
                    db.Volunteers.Add(volunteer);
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    return(BadRequest("操作发生错误"));
                }
            }
            //2.已存在的手机号码
            else
            {
                //排除已经提交手机号码但未进行验证的情况
                if (volunteer.Status == EnumUserStatus.注册未验证手机)
                {
                    return(BadRequest("该手机号码已注册"));
                }
                volunteer.SmsCaptcha        = code;
                volunteer.SmsCaptchaUsedFor = EnumCaptchaUsedFor.志愿者注册;
                DateTime now = DateTime.Now;
                volunteer.SmsCaptchaExpiredTime = now.AddMinutes(30);
                db.Entry(volunteer).State       = EntityState.Modified;
                try
                {
                    db.SaveChanges();
                }
                catch (Exception ex)
                {
                    db.Entry(volunteer).State = EntityState.Unchanged;
                    return(BadRequest("操作发生错误"));
                }
            }

#if !DEBUG
            if (!Ali.SendWorkerRegisterSms(code, model.MobileNumber))
            {
                //发送错误不处理
            }
#endif

            return(Ok());
        }
Ejemplo n.º 30
0
        private void Validate(Volunteer volunteer, List <JobRole> jobRoles, List <Technology> technologies)
        {
            if (String.IsNullOrEmpty(volunteer.FirstName))
            {
                ModelState.AddModelError("FirstName", "First Name is Required");
            }

            if (volunteer.FirstName != null)
            {
                if (volunteer.FirstName.Length > 30)
                {
                    ModelState.AddModelError("FirstName", "First name cannot exceed 30 characters");
                }
            }

            if (String.IsNullOrEmpty(volunteer.LastName))
            {
                ModelState.AddModelError("LastName", "Last Name is Required");
            }

            if (volunteer.LastName != null)
            {
                if (volunteer.LastName.Length > 30)
                {
                    ModelState.AddModelError("LastName", "Last name cannot exceed 30 characters");
                }
            }

            if (String.IsNullOrEmpty(volunteer.EmailAddress))
            {
                ModelState.AddModelError("EmailAddress", "Email Address is Required");
            }

            if (volunteer.TeamName != null)
            {
                if (volunteer.TeamName.Length > 30)
                {
                    ModelState.AddModelError("TeamName", "Team Name cannot exceed 30 characters");
                }
            }

            if (volunteer.EmailAddress != null)
            {
                if (volunteer.EmailAddress.Length > 255)
                {
                    ModelState.AddModelError("EmailAddress", "Email Address cannot exceed 250 characters");
                }
            }

            if (String.IsNullOrEmpty(volunteer.PhoneNumber))
            {
                ModelState.AddModelError("PhoneNumber", "Phone Number is Required");
            }

            if (volunteer.PhoneNumber != null)
            {
                if (volunteer.PhoneNumber.Length > 50)
                {
                    ModelState.AddModelError("PhoneNumber", "Phone Number cannot exceed 50 characters");
                }
            }

            if (jobRoles.Count == 0)
            {
                ModelState.AddModelError("Roles", "You have to enter at least one role");
            }

            if (String.IsNullOrEmpty(volunteer.JobDescription))
            {
                ModelState.AddModelError("JobDescription", "Day job is Required");
            }

            if (volunteer.JobDescription != null)
            {
                if (volunteer.JobDescription.Length > 100)
                {
                    ModelState.AddModelError("JobDescription", "Day job cannot exceed 100 characters");
                }
            }

            if (technologies.Count == 0)
            {
                ModelState.AddModelError("Technologies", "You have to enter at least one technology");
            }

            if (volunteer.YearsOfExperience == null)
            {
                ModelState.AddModelError("YearsOfExperience", "Years of Experience is required");
            }

            if (volunteer.DietaryNeeds != null)
            {
                if (volunteer.DietaryNeeds.Length > 50)
                {
                    ModelState.AddModelError("DietaryNeeds", "Dietary needs cannot exceed 50 characters");
                }
            }

            if (volunteer.TwitterHandle != null)
            {
                if (volunteer.TwitterHandle.Length > 50)
                {
                    ModelState.AddModelError("TwitterHandle", "Twitter handle cannot exceed 50 characters");
                }
            }

            if (volunteer.Bio != null)
            {
                if (volunteer.Bio.Length > 4000)
                {
                    ModelState.AddModelError("Bio", "Bio cannot exceed 4000 characters");
                }
            }

            if (volunteer.Comments != null)
            {
                if (volunteer.Comments.Length > 4000)
                {
                    ModelState.AddModelError("Comments", "Comments cannot exceed 4000 characters");
                }
            }
        }
        private async void AttachRequirement(Requirement theRequirement, Senior theSenior = null, Volunteer theVolunteer = null, string additionalInformation = null)
        {
            //first we check to see who is getting the requirement
            bool isSenior;

            if (theSenior == null)
                isSenior = true;
            else if (theVolunteer == null)
                isSenior = false;
            else
                return;

            if (isSenior)
            {
                SeniorRequirements req = new SeniorRequirements();
                req.RequirementID = theRequirement.ID;
                req.SeniorID = theSenior.ID;
                req.AdditionalInformation = additionalInformation;

                await _seniorRequirements.InsertAsync(req);
            }
            else
            {
                VolunteerRequirements req = new VolunteerRequirements();
                req.RequirementID = theRequirement.ID;
                req.VolunteerID = theVolunteer.ID;

                await _volunteerRequirements.InsertAsync(req);
            }
        }
Ejemplo n.º 32
0
 partial void InsertVolunteer(Volunteer instance);
Ejemplo n.º 33
0
        /// <summary>
        /// InsertVolunteer
        /// </summary>
        /// <param name="key"></param>
        /// <param name="wardName"></param>
        /// <returns></returns>
        public int InsertVolunteer(string key, string wardName)
        {
            try
            {
                var user = context.Auths.Where(@w => @w.Key == key).First();
                var ward = context.Wards.Where(@w => @w.Name.Trim() == wardName).First();
                var zone = context.Zones.Where(@w => @w.Id == ward.ZoneId).First();
                string topicName = zone.Name.Replace('"', ' ').Trim() + "-" + ward.Name.Replace('"', ' ').Trim();
                var topic = context.Topics.Where(@w => @w.Name == topicName).First();

                Volunteer volunteer = new Volunteer()
                {
                    Id = Guid.NewGuid(),
                    UserId = user.UserId,
                    WardId = ward.Id
                };

                var volunteers = context.Volunteers.Where(@w => @w.UserId == user.UserId);

                if (volunteers != null && volunteers.Count() > 0)
                {
                    return 104;
                }

                context.Volunteers.InsertOnSubmit(volunteer);
                SubmitData();

                TopicUserMap topicUserMap = new TopicUserMap
                {
                    Id = Guid.NewGuid(),
                    TopicId = topic.Id,
                    UserId = user.Id
                };

                context.TopicUserMaps.InsertOnSubmit(topicUserMap);
                SubmitData();

                InsertVolunteerRegistrationPoints(user.Id);

                return 215;
            }
            catch (Exception ex)
            {
                return 100;
            }
        }
Ejemplo n.º 34
0
		public static Volunteer GetByID(int volunteerId)
		{
			Volunteer volunteer = null;
			
			var connector = new Connector(BasicQuery +
			                              " WHERE Volunteers.ID = @VolunteerID " +
			                              " ORDER BY Volunteers.Surname ");
			
			connector.AddParameter("@VolunteerID", volunteerId);
			
			var table = connector.ExecuteDataTable();
			connector = null;
			
			if(table.Rows.Count == 1)
			{
				volunteer = new Volunteer(table.Rows[0]);
			}
			
			return volunteer;
		}
Ejemplo n.º 35
0
    private void NotifyAboutLostVolunteer (Person oldOwner, Volunteer volunteer, Person viewingPerson)
    {
        //"A volunteer for officer duty, {0}, was previously assigned to you, but was now taken over by {1} again." +

        string mailbody = this.GetLocalResourceObject("RevokedMailMessage").ToString();
        string mailSubject = this.GetLocalResourceObject("RevokedMailSubject").ToString();


        mailbody = string.Format(mailbody, volunteer.Name, viewingPerson.Name);

        oldOwner.SendOfficerNotice(mailSubject, mailbody, Organization.PPSEid);
    }
Ejemplo n.º 36
0
        public ActionResult Create()
        {
            var volunteer = new Volunteer();

            return(View());
        }
Ejemplo n.º 37
0
    private void NotifyAboutAssignedVolunteer (Person person, Volunteer volunteer)
    {
        //"A volunteer for officer duty, {0}, was just assigned to you. " +
        //"Please check this at https://pirateweb.net/Pages/v4/ListVolunteers.aspx and delegate or " +
        //"process as soon as possible. The person volunteers for the following roles:\r\n\r\n "+
        //"{1}" +
        //"\r\nAs a general rule, leads should be assigned by the lead immediately above " +
        //"them in the org, and vices and admins should be assigned by the lead in the same area. " +
        //"Delegate the assessment and assignment to the correct person.\r\n";

        string mailbody = this.GetLocalResourceObject("AssignmentMailMessage").ToString();
        string mailbodyInclusion = this.GetLocalResourceObject("AssignmentMailInclusion").ToString();
        string mailSubject = this.GetLocalResourceObject("AssignmentMailSubject").ToString();

        VolunteerRoles roles = volunteer.Roles;
        string rolesString = "";
        foreach (VolunteerRole role in roles)
        {
            rolesString += string.Format("\r\n" + mailbodyInclusion, role.RoleType.ToString(), role.Geography.Name);
        }

        mailbody = string.Format(mailbody, volunteer.Name, rolesString);

        person.SendOfficerNotice(mailSubject, mailbody, Organization.PPSEid);
    }
 private async void AddVolunteer(Volunteer newVolunteer)
 {
     await volunteerTable.InsertAsync(newVolunteer);
 }
Ejemplo n.º 39
0
 partial void UpdateVolunteer(Volunteer instance);
        public IHttpActionResult UpdateVolunteerPic(int id)
        {

            bool haspic = false;
            string picextension;
            if (Request.Content.IsMimeMultipartContent())
            {
                Debug.WriteLine("Received multipart form data.");

                int numfiles = HttpContext.Current.Request.Files.Count;
                Debug.WriteLine("Files Received: " + numfiles);

                //Check if a file is posted
                if (numfiles == 1 && HttpContext.Current.Request.Files[0] != null)
                {
                    var VolunteerPic = HttpContext.Current.Request.Files[0];
                    //Check if the file is empty
                    if (VolunteerPic.ContentLength > 0)
                    {
                        var valtypes = new[] { "jpeg", "jpg", "png", "gif" };
                        var extension = Path.GetExtension(VolunteerPic.FileName).Substring(1);
                        //Check the extension of the file
                        if (valtypes.Contains(extension))
                        {
                            try
                            {
                                //file name is the id of the image
                                string fn = id + "." + extension;

                                //get a direct file path to ~/Content/Volunteers/{id}.{extension}
                                string path = Path.Combine(HttpContext.Current.Server.MapPath("~/Content/Volunteers/"), fn);

                                //save the file
                                VolunteerPic.SaveAs(path);
                                Debug.WriteLine("Path:" + path);

                                //if these are all successful then we can set these fields
                                haspic = true;
                                picextension = extension;
                                Debug.WriteLine("fn" + fn);

                                //Update the volunteer haspic and picextension fields in the database
                                Volunteer SelectedVolunteer = db.Volunteers.Find(id);
                                SelectedVolunteer.VolunteerHasPic = haspic;
                                SelectedVolunteer.PicExtension = extension;
                                db.Entry(SelectedVolunteer).State = EntityState.Modified;

                                db.SaveChanges();

                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine("Volunteer Image was not saved successfully.");
                                Debug.WriteLine("Exception:" + ex);
                            }
                        }
                    }

                }
            }

            return Ok();
        }
Ejemplo n.º 41
0
 partial void DeleteVolunteer(Volunteer instance);
Ejemplo n.º 42
0
 public SignUpViewModel(Volunteer volunteer)
 {
     Construct(volunteer);
 }
Ejemplo n.º 43
0
	private void attach_Volunteers(Volunteer entity)
	{
		this.SendPropertyChanging();
		entity.Entity = this;
	}
Ejemplo n.º 44
0
        public IHttpActionResult PostRegister(Register model)
        {
            DateTime now = DateTime.Now;
            //验证Andriod手机端
            IEnumerable <string> headUuid = null;

            ActionContext.Request.Headers.TryGetValues("uuid", out headUuid);
            string uuid = null;

            if (headUuid != null)
            {
                uuid = headUuid.ToList()[0];
            }
            //验证数据
            if (model == null)
            {
                return(BadRequest("请填写注册信息"));
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.Values.First(s => s.Errors.Count > 0).Errors[0].ErrorMessage));
            }
            Volunteer volunteer = db.Volunteers.FirstOrDefault(s => s.MobileNumber == model.MobileNumber && s.Status != EnumUserStatus.注销);

            //未点击获取验证码
            if (volunteer == null)
            {
                return(BadRequest("请获取验证码"));
            }
            //手机号码已注册
            if (volunteer.Status == EnumUserStatus.注册未验证手机)
            {
                return(BadRequest("该手机号码已注册"));
            }
            //数据库中不存在验证码
            if (string.IsNullOrEmpty(volunteer.SmsCaptcha))
            {
                return(BadRequest("请获取验证码"));
            }
            //验证码用途不正确
            if (!volunteer.SmsCaptchaUsedFor.HasValue || volunteer.SmsCaptchaUsedFor != EnumCaptchaUsedFor.志愿者注册)
            {
                return(BadRequest("验证码无效,请重新获取验证码"));
            }
            //验证码失效
            if (volunteer.SmsCaptchaExpiredTime > now)
            {
                return(BadRequest("验证码失效,请重新获取"));
            }
            //验证码错误
            if (volunteer.SmsCaptcha != model.Captcha)
            {
                return(BadRequest("验证码错误"));
            }

            //注册,生成token
            volunteer.Uuid                  = uuid;
            volunteer.Password              = SecurityHelper.MD5Hash(model.PassWord);
            volunteer.SmsCaptcha            = null;
            volunteer.SmsCaptchaExpiredTime = null;
            volunteer.SmsCaptchaUsedFor     = null;
            volunteer.Status                = EnumUserStatus.注册中;
            volunteer.RegisterTime          = now;
            db.Entry(volunteer).State       = EntityState.Modified;
            try
            {
                db.SaveChanges();
                VolunteerToken volunteerToken = db.VolunteerTokens.FirstOrDefault(s => s.VolunteerId == volunteer.Id);
                string         token          = SecurityHelper.MD5Hash(volunteer.Id.ToString() + now.ToString() + Guid.NewGuid().ToString());
                if (volunteerToken == null)
                {
                    volunteerToken = new VolunteerToken
                    {
                        VolunteerId = volunteer.Id,
                        Token       = token,
                        CreateTime  = now,
                        ActiveTime  = now,
                        Validity    = 30
                    };
                    db.VolunteerTokens.Add(volunteerToken);
                    db.SaveChanges();
                }
                else
                {
                    volunteerToken.ActiveTime      = now;
                    volunteerToken.Token           = token;
                    volunteerToken.Validity        = 30;
                    db.Entry(volunteerToken).State = EntityState.Modified;
                    db.SaveChanges();
                }
                return(Ok(
                           new { Token = token, Volunteer = VolunteerService.FormatUser(volunteer) }
                           ));
            }
            catch (Exception ex)
            {
                db.Entry(volunteer).State = EntityState.Unchanged;
                return(BadRequest("操作发生错误"));
            }
        }
Ejemplo n.º 45
0
	private void detach_Volunteers(Volunteer entity)
	{
		this.SendPropertyChanging();
		entity.Entity = null;
	}
Ejemplo n.º 46
0
 public static PositionEvlTable_M ToViewModel(List <EntEvaluateStu> EntEvaStu, UserInfo StuAllInfo, Volunteer volunteer, T_StuBatchReg AllComment)
 {
     if (volunteer == null)
     {
         return(new PositionEvlTable_M()
         {
             EntEvaStu = EntEvaStu,
             StuName = StuAllInfo.Name,
             EntName = "暂无企业录用",
             PositionName = "暂无企业录用",
             AllComment = AllComment,
             StuAllInfo = StuAllInfo,
             PracticeDept = "暂无企业录用",
             PracticeDivDept = "暂无企业录用",
         });
     }
     else
     {
         return(new PositionEvlTable_M()
         {
             EntEvaStu = EntEvaStu,
             StuName = StuAllInfo.Name,
             EntName = volunteer.EntName,
             PositionName = volunteer.PositionName,
             AllComment = AllComment,
             StuAllInfo = StuAllInfo,
             PracticeDept = volunteer.PracticeDept,
             PracticeDivDept = volunteer.PracticeDivDept
         });
     }
 }
Ejemplo n.º 47
0
        public static void SendVolunteerApplicationEmail(Volunteer volunteer)
        {
            string Subject = "New Volunteer Application - " + volunteer.Name;

            string HTMLBody =
                "<p>An application was submitted by " + volunteer.Name + " to become a volunteer at AWIC. </p>" +
                "<br />" +
                "<p>Here is the application: </p>" +
                "<p>Name: " + volunteer.Name + "</p>" +
                "<p>Address: " + volunteer.Address + "</p>" +
                "<p>City: " + volunteer.City + "</p>" +
                "<p>Province or State: " + volunteer.ProvinceOrState + "</p>" +
                "<p>Country: " + volunteer.Country + "</p>" +
                "<p>Postal Code: " + volunteer.PostalCode + "</p>" +
                "<p>Phone Number: " + volunteer.Phone + "</p>" +
                "<p>E-mail Address: " + volunteer.EmailAddress + "</p>" +
                ( volunteer.DateOfBirth != null ? "<p>Date of Birth: " + ((DateTime)volunteer.DateOfBirth).ToLongDateString() + "</p>" : "" ) +
                ( !String.IsNullOrEmpty(volunteer.LanguagesSpokenFluently) ? "<p>Languages Spoken Fluently: " + volunteer.LanguagesSpokenFluently + "</p>" : "" ) +
                "<p>Qualifications: </p>" +
                "<p>" + volunteer.Qualifications + "</p>" +
                "<p>Days and Times Available: </p>" +
                ( volunteer.Monday    ? "<p>Monday"    + ( !String.IsNullOrEmpty(volunteer.MondayTimes)    ? ": " + volunteer.MondayTimes    : "" ) + "</p>" : "" ) +
                ( volunteer.Tuesday   ? "<p>Tuesday"   + ( !String.IsNullOrEmpty(volunteer.TuesdayTimes)   ? ": " + volunteer.TuesdayTimes   : "" ) + "</p>" : "" ) +
                ( volunteer.Wednesday ? "<p>Wednesday" + ( !String.IsNullOrEmpty(volunteer.WednesdayTimes) ? ": " + volunteer.WednesdayTimes : "" ) + "</p>" : "" ) +
                ( volunteer.Thursday  ? "<p>Thursday"  + ( !String.IsNullOrEmpty(volunteer.ThursdayTimes)  ? ": " + volunteer.ThursdayTimes  : "" ) + "</p>" : "" ) +
                ( volunteer.Friday    ? "<p>Friday"    + ( !String.IsNullOrEmpty(volunteer.FridayTimes)    ? ": " + volunteer.FridayTimes    : "" ) + "</p>" : "" ) +
                ( volunteer.Saturday  ? "<p>Saturday"  + ( !String.IsNullOrEmpty(volunteer.SaturdayTimes)  ? ": " + volunteer.SaturdayTimes  : "" ) + "</p>" : "" ) +
                ( volunteer.Sunday    ? "<p>Sunday"    + ( !String.IsNullOrEmpty(volunteer.SundayTimes)    ? ": " + volunteer.SundayTimes    : "" ) + "</p>" : "" );

            SendEmail(System.Configuration.ConfigurationManager.AppSettings["OrganisationEmailAddress"], Subject, HTMLBody);
        }
Ejemplo n.º 48
0
 public Task <int> UpdateVolunteerAsync(Volunteer obj)
 {
     return(_database.UpdateAsync(obj));
 }
Ejemplo n.º 49
0
        public void Save(Volunteer volunteer)
        {
            if (volunteer.Id == 0)
            {
                _dataContext.Volunteers.Add(volunteer);
                _dataContext.SaveChanges();
            }

            if (volunteer.Id != 0 && volunteer.JobRoles != null && volunteer.JobRoles.Count > 0)
            {
                foreach (var volunteerJobRole in _dataContext.VolunteerJobRoles.Where(vjr => vjr.VolunteerId == volunteer.Id))
                {
                    if (!volunteer.JobRoles.Any(jr => jr.Id == volunteerJobRole.JobRoleId))
                        _dataContext.VolunteerJobRoles.Remove(volunteerJobRole);
                }
                _dataContext.SaveChanges();

                foreach (var jobRole in volunteer.JobRoles.Where(jr => !_dataContext.VolunteerJobRoles.Any(vjr => vjr.JobRoleId == jr.Id)))
                {
                    _dataContext.VolunteerJobRoles.Add(new VolunteerJobRole()
                    {
                        VolunteerId = volunteer.Id,
                        JobRoleId = jobRole.Id
                    });
                }
                _dataContext.SaveChanges();
            }

            if (volunteer.Id != 0 && volunteer.Technologies != null && volunteer.Technologies.Count > 0)
            {
                foreach (var volunteerTechnology in _dataContext.VolunteerTechnologies.Where(vt => vt.VolunteerId == volunteer.Id))
                {
                    if (!volunteer.Technologies.Any(t => t.Id == volunteerTechnology.TechnologyId))
                        _dataContext.VolunteerTechnologies.Remove(volunteerTechnology);
                }
                _dataContext.SaveChanges();

                foreach (var technology in volunteer.Technologies.Where(t => !_dataContext.VolunteerTechnologies.Any(vt => vt.TechnologyId == t.Id)))
                {
                    _dataContext.VolunteerTechnologies.Add(new VolunteerTechnology()
                    {
                        VolunteerId = volunteer.Id,
                        TechnologyId = technology.Id
                    });
                }
                _dataContext.SaveChanges();
            }

            _dataContext.SaveChanges();
        }
Ejemplo n.º 50
0
    protected void ButtonSubmit_Click(object sender, EventArgs e)
    {
        string    responsibilities = string.Empty;
        Geography geography        = Geography.FromIdentity(Int32.Parse(this.DropGeographies.SelectedValue));

        // Find: is this an existing person?

        Person person = null;

        //TODO: Hardcoded countrycode = 1
        People people = People.FromPhoneNumber(1, this.TextPhone.Text);

        if (people.Count == 1)
        {
            if (people[0].Name.ToLower() == this.TextName.Text.ToLower())
            {
                person = people[0];
            }
        }

        // If not, create one for this purpose

        if (person == null)
        {
            person           = Person.Create(this.TextName.Text, string.Empty, string.Empty, this.TextPhone.Text, string.Empty, string.Empty, string.Empty, "SE", DateTime.Now, PersonGender.Unknown);
            person.Geography = geography;
        }
        Person    defaultOwner = Person.FromIdentity(1);
        Volunteer volunteer    = Volunteer.Create(person, defaultOwner); // RF owns new volunteers

        if (this.CheckKL1.Checked)
        {
            responsibilities += " KL1";
            volunteer.AddRole(Organization.PPSEid, geography.Identity, RoleType.LocalLead);
        }

        if (this.CheckKL2.Checked)
        {
            responsibilities += " KL2";
            volunteer.AddRole(Organization.PPSEid, geography.Identity, RoleType.LocalDeputy);
        }


        // Move "geography" up to electoral circuit level
        while ((!geography.AtLevel(GeographyLevel.ElectoralCircuit)) && (geography.Parent != null))
        {
            geography = geography.Parent;
        }

        //Autoassign will try to assign to ElectoralCircuit lead or
        //if not possible, to its parent org lead, or if not possible to defaultOwner
        //TODO:Hardcoded sweden(30)
        volunteer.AutoAssign(geography, Organization.PPSEid, defaultOwner, Geography.SwedenId);

        if (this.CheckVL1.Checked)
        {
            responsibilities += " VL1";
            volunteer.AddRole(Organization.PPSEid, geography.Identity, RoleType.LocalLead);
        }

        if (this.CheckVL2.Checked)
        {
            responsibilities += " VL2";
            volunteer.AddRole(Organization.PPSEid, geography.Identity, RoleType.LocalDeputy);
        }

        responsibilities = responsibilities.Trim();

        string textParameter = this.TextName.Text.Replace("|", "") + "|" + this.TextPhone.Text.Replace("|", "") + "|" + this.DropMember.SelectedValue + "|" + responsibilities;

        Activizr.Logic.Support.PWEvents.CreateEvent(EventSource.SignupPage, EventType.NewVolunteer, 0, Organization.PPSEid, Int32.Parse(this.DropGeographies.SelectedValue), 0, 0, textParameter);

        this.TextName.Enabled        = false;
        this.TextPhone.Enabled       = false;
        this.DropGeographies.Enabled = false;
        this.DropMember.Enabled      = false;
        this.CheckKL1.Enabled        = false;
        this.CheckKL2.Enabled        = false;
        this.CheckVL1.Enabled        = false;
        this.CheckVL2.Enabled        = false;
        this.ButtonSubmit.Enabled    = false;

        this.PanelFinished.Visible = true;
    }
Ejemplo n.º 51
0
        // when user join project
        //
        public Boolean joinUserToPreject(int userId, int projectId)
        {
            using (Youth_Center_DB_Conn db = new Youth_Center_DB_Conn())
            {
                try
                {
                    var projects = from p in db.ProjectSets
                                   where p.Id == projectId
                                   select p;
                    if (projects.Any())
                    {
                        ProjectSet project = projects.First();

                        var users = from user in db.ProjectLaucherSets
                                    where user.Id == userId
                                    select user;
                        if (users.Any())
                        {
                            ProjectLaucherSet user = users.First();
                            Boolean duplicate = false;

                            foreach (Volunteer v in project.Volunteers)
                            {
                                if (v.LaucherId == userId)
                                    duplicate = true;
                            }

                            if (!duplicate)
                            {
                                Volunteer volunteer = new Volunteer();
                                volunteer.LaucherId = userId;
                                volunteer.role = user.role;
                                project.Volunteers.Add(volunteer);

                                return true;
                            }
                        }

                    }
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.StackTrace);
                }
                return false;
            }
        }