Exemplo n.º 1
0
        public ContentResult BuildingCheckin(int id, string location, int accesstype, int? guestof)
        {
            if (!Authenticate())
                return Content("not authorized");

            CheckInTime g = null;

            if (guestof != null)
            {
                g = (from e in DbUtil.Db.CheckInTimes
                     where e.Id == guestof
                     select e).FirstOrDefault();
            }

            var reader = new StreamReader(Request.InputStream);
            var s = reader.ReadToEnd();

            if (!s.HasValue())
                s = "<Activities />";

            var xs = new XmlSerializer(typeof (List<Activity>), new XmlRootAttribute("Activities"));
            var activities = xs.Deserialize(new StringReader(s)) as List<Activity>;

            var last = from e in DbUtil.Db.CheckInTimes
                       where e.PeopleId == id
                       where e.CheckInTimeX <= DateTime.Now
                       where e.CheckInTimeX >= DateTime.Now.AddHours(-1.5)
                       select e;

            if (guestof == null)
            {
                last = from f in last
                       where f.GuestOfId == null
                       select f;
            }
            else
            {
                last = from f in last
                       where f.GuestOfId == guestof
                       select f;
            }

            CheckInTime ac = null;

            if (last.Any())
            {
                ac = last.Single();

                foreach (var e in ac.CheckInActivities)
                    DbUtil.Db.CheckInActivities.DeleteOnSubmit(e);

                DbUtil.Db.SubmitChanges();

                foreach (var a in activities)
                    ac.CheckInActivities.Add(new CheckInActivity {Activity = a.Name});

                ac.AccessTypeID = accesstype;
            }
            else
            {
                ac = new CheckInTime
                {
                    PeopleId = id,
                    Location = location,
                    CheckInTimeX = DateTime.Now,
                    GuestOfId = guestof,
                    GuestOfPersonID = (g != null ? g.PeopleId ?? 0 : 0),
                    AccessTypeID = accesstype
                };

                foreach (var a in activities)
                    ac.CheckInActivities.Add(new CheckInActivity {Activity = a.Name});

                DbUtil.Db.CheckInTimes.InsertOnSubmit(ac);
            }


            DbUtil.Db.SubmitChanges();

            foreach (var a in activities)
            {
                if (a.org > 0)
                    Attend.RecordAttend(DbUtil.Db, id, a.org, true, DateTime.Today);
            }

            return Content(ac.Id.ToString());
        }
Exemplo n.º 2
0
 public JsonResult PostCheckIn(int id, string KeyCode)
 {
     Session["CheckInOrgId"] = id;
     var q = from kc in DbUtil.Db.CardIdentifiers
             where KeyCode == kc.Id
             select kc.PeopleId;
     var pid = q.SingleOrDefault();
     if (pid > 0)
     {
         var dt = Util.Now;
         var ck = new CheckInTime
         {
             CheckInTimeX = dt,
             PeopleId = pid
             //KeyCode = KeyCode
         };
         DbUtil.Db.CheckInTimes.InsertOnSubmit(ck);
         DbUtil.Db.SubmitChanges();
     }
     return Json(new {pid});
 }
Exemplo n.º 3
0
 private void detach_Guests(CheckInTime entity)
 {
     this.SendPropertyChanging();
     entity.GuestOf = null;
 }
Exemplo n.º 4
0
		private void detach_CheckInTimes(CheckInTime entity)
		{
			this.SendPropertyChanging();
			entity.Person = null;
		}
Exemplo n.º 5
0
		private void detach_Guests(CheckInTime entity)
		{
			this.SendPropertyChanging();
			entity.GuestOf = null;
		}