Пример #1
0
        public ActionResult ManageVolunteer(string id, int?pid)
        {
            if (!id.HasValue())
            {
                return(Content("bad link"));
            }
            VolunteerModel m = null;

            var td = TempData["ps"];

            if (td != null)
            {
                m = new VolunteerModel(orgId: id.ToInt(), peopleId: td.ToInt());
            }
            else if (pid.HasValue)
            {
                var leader = OrganizationModel.VolunteerLeaderInOrg(id.ToInt2());
                if (leader)
                {
                    m = new VolunteerModel(orgId: id.ToInt(), peopleId: pid.Value, leader: 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(orgId: a[0].ToInt(), peopleId: a[1].ToInt());
                id      = a[0];
                ot.Used = true;
                DbUtil.Db.SubmitChanges();
            }

            SetHeaders(id.ToInt());
            DbUtil.LogActivity("Pick Slots: {0} ({1})".Fmt(m.Org.OrganizationName, m.Person.Name));
            return(View(m));
        }
        public VolunteerCommitmentsModel(int id)
        {
            OrgName = (from o in DbUtil.Db.Organizations where o.OrganizationId == id select o.OrganizationName).Single();
            OrgId   = id;
            times   = from ts in Regsettings.TimeSlots.list
                      orderby ts.Time
                      select ts.Datetime(Sunday);

            IsLeader = OrganizationModel.VolunteerLeaderInOrg(id);
        }