示例#1
0
        public ActionResult ConfirmVolunteerSlots(VolunteerModel m)
        {
            m.UpdateCommitments();
            if (m.SendEmail || !m.IsLeader)
            {
                List<Person> Staff = null;
                Staff = DbUtil.Db.StaffPeopleForOrg(m.OrgId);
                var staff = Staff[0];

                var summary = m.Summary(this);
                var text = Util.PickFirst(m.Setting.Body, "confirmation email body not found");
                text = text.Replace("{church}", DbUtil.Db.Setting("NameOfChurch", "church"), true);
                text = text.Replace("{name}", m.Person.Name, true);
                text = text.Replace("{date}", DateTime.Now.ToString("d"), true);
                text = text.Replace("{email}", m.Person.EmailAddress, true);
                text = text.Replace("{phone}", m.Person.HomePhone.FmtFone(), true);
                text = text.Replace("{contact}", staff.Name, true);
                text = text.Replace("{contactemail}", staff.EmailAddress, true);
                text = text.Replace("{contactphone}", m.Org.PhoneNumber.FmtFone(), true);
                text = text.Replace("{details}", summary, true);
                DbUtil.Db.Email(staff.FromEmail, m.Person, m.Setting.Subject, text);

                DbUtil.Db.Email(m.Person.FromEmail, Staff, "Volunteer Commitments managed", $@"{m.Person.Name} managed volunteer commitments to {m.Org.OrganizationName}<br/>
            The following Committments:<br/>
            {summary}");
            }
            ViewData["Organization"] = m.Org.OrganizationName;
            SetHeaders(m.OrgId);
            if (m.IsLeader)
                return View("ManageVolunteer/PickSlots", m);
            return View("ManageVolunteer/ConfirmVolunteerSlots", m);
        }
示例#2
0
        public ActionResult ManageVolunteer(string id, int? pid)
        {
            if (!id.HasValue())
                return Content("bad link");
            VolunteerModel m = null;

            var td = TempData["PeopleId"];
            if (td != null)
            {
                m = new VolunteerModel(id.ToInt(), td.ToInt());
            }
            else if (pid.HasValue)
            {
                var leader = OrganizationMember.VolunteerLeaderInOrg(DbUtil.Db, id.ToInt2());
                if (leader)
                    m = new VolunteerModel(id.ToInt(), pid.Value, true);
            }
            if (m == null)
            {
                var guid = id.ToGuid();
                if (guid == null)
                    return Content("invalid link");
                var ot = DbUtil.Db.OneTimeLinks.SingleOrDefault(oo => oo.Id == guid.Value);
                if (ot == null)
                    return Content("invalid link");
#if DEBUG2
#else
                if (ot.Used)
                    return Content("link used");
#endif
                if (ot.Expires.HasValue && ot.Expires < DateTime.Now)
                    return Content("link expired");
                var a = ot.Querystring.Split(',');
                m = new VolunteerModel(a[0].ToInt(), a[1].ToInt());
                id = a[0];
                ot.Used = true;
                DbUtil.Db.SubmitChanges();
            }

            SetHeaders(id.ToInt());
            DbUtil.LogActivity($"Pick Slots: {m.Org.OrganizationName} ({m.Person.Name})");
            return View("ManageVolunteer/PickSlots", m);
        }