public IHttpActionResult TagAttendeeInByID(int rfid, int agendaID, int?activityID, string dir) { Attendee retVal = new Attendee(); retVal.LastName = "None Found"; int actID = -1; if (activityID > 0) { actID = activityID ?? default(int); } // find attendee by RFID Attendee found = db.Attendees.Where(o => o.RfID == rfid.ToString()).FirstOrDefault(); dynamic retJSON = new ExpandoObject(); retJSON.Attendee = retVal; retJSON.DuplicateCheckin = false; // if found, insert a TagIn for this Attendee and return the object if (found != null) { retVal = found; // check to see if this is a duplicate check AttendeeLastCheck confirm = db.AttendeeLastChecks.Where(o => o.AttendeeID == found.ID).OrderByDescending(o => o.LastUpdate).FirstOrDefault(); if (confirm != null) { if (confirm.LastAgenda == agendaID && confirm.LastActivity == actID && confirm.CheckDir == dir) { // this is a duplicate retJSON.DuplicateCheckin = true; } } if (retJSON.DuplicateCheckin == false) { AttendeeLastCheck tagIn = new AttendeeLastCheck(); tagIn.AgendaID = agendaID; tagIn.AttendeeID = found.ID; tagIn.LastActivity = activityID; tagIn.LastAgenda = agendaID; tagIn.LastUpdate = DateTime.Now; tagIn.CheckDir = dir; db.AttendeeLastChecks.Add(tagIn); db.SaveChanges(); } retJSON.Attendee = found; } retJSON.CheckedInCount = ATAPS_Pile.GetActivityAttendeeCurrentCountByActivityID(actID, agendaID); return(Ok(retJSON)); }
public IHttpActionResult GetActivityByID(int filter) { ActivityDisplayObject retVal = new ActivityDisplayObject(); if (filter > 0) { retVal.Activity = db.Activities.Where(o => o.ID == filter).FirstOrDefault(); retVal.ActivityDetail = db.ActivityDetails.Where(o => o.ActivityID == filter).FirstOrDefault(); retVal.ActivityType = db.ActivityTypes.Where(o => o.ID == retVal.Activity.ActivityTypeID).FirstOrDefault(); int accessEventID = int.Parse(ConfigurationManager.AppSettings["ActiveEvent"]); retVal.CheckedInCount = ATAPS_Pile.GetActivityAttendeeCurrentCountByActivityID(retVal.Activity.ID, retVal.Activity.AgendaID); } return(Ok(retVal)); }