Rock.Model.AttendanceService.Get C# (CSharp) Méthode

Get() public méthode

Returns a specific Rock.Model.Attendance record.
public Get ( System.DateTime date, int locationId, int scheduleId, int groupId, int personId ) : Attendance
date System.DateTime A representing the the date attended.
locationId int A representing the Id of the
scheduleId int A representing the Id of the
groupId int A representing the Id of the .
personId int A representing the Id of the
Résultat Attendance
        public Attendance Get( DateTime date, int locationId, int scheduleId, int groupId, int personId )
        {
            DateTime beginDate = date.Date;
            DateTime endDate = beginDate.AddDays( 1 );

            return Queryable( "Group,Schedule,PersonAlias.Person" )
                .Where( a =>
                    a.StartDateTime >= beginDate &&
                    a.StartDateTime < endDate &&
                    a.LocationId == locationId &&
                    a.ScheduleId == scheduleId &&
                    a.GroupId == groupId &&
                    a.PersonAlias.PersonId == personId )
                .FirstOrDefault();
        }

Usage Example

        protected void btnSave_Click(object sender, EventArgs e)
        {
            btnDone.Visible = true;
            lblPeople.Visible = true;

            //Create List to Save Registered People

            var peopleList = new List<string>();

            if (Session["peopleList"] != null)
            {
            peopleList = (List<string>)Session["peopleList"];
            }

            AttendanceCodeService attendanceCodeService = new AttendanceCodeService(rockContext);
            AttendanceService attendanceService = new AttendanceService(rockContext);
            GroupMemberService groupMemberService = new GroupMemberService(rockContext);
            PersonAliasService personAliasService = new PersonAliasService(rockContext);

            Session["person"] = ppPerson.SelectedValue.ToString();

            // Only create one attendance record per day for each person/schedule/group/location
            DateTime theTime = Convert.ToDateTime(Session["startDateTime"]);
            var attendance = attendanceService.Get(theTime, int.Parse(Session["location"].ToString()), int.Parse(Session["schedule"].ToString()), int.Parse(Session["group"].ToString()), int.Parse(ppPerson.SelectedValue.ToString()));
            var primaryAlias = personAliasService.GetPrimaryAlias(int.Parse(ppPerson.SelectedValue.ToString()));

            if (attendance == null)
            {

                if (primaryAlias != null)
                {
                    attendance = rockContext.Attendances.Create();
                    attendance.LocationId = int.Parse(Session["location"].ToString());
                    attendance.CampusId = int.Parse(Session["campus"].ToString());
                    attendance.ScheduleId = int.Parse(Session["schedule"].ToString());
                    attendance.GroupId = int.Parse(Session["group"].ToString());
                    attendance.PersonAlias = primaryAlias;
                    attendance.PersonAliasId = primaryAlias.Id;
                    attendance.DeviceId = null;
                    attendance.SearchTypeValueId = 1;
                    attendanceService.Add(attendance);
                }
            }
            attendance.AttendanceCodeId = null;
            attendance.StartDateTime = Convert.ToDateTime(Session["startDateTime"]);
            attendance.EndDateTime = null;
            attendance.DidAttend = true;

            //KioskLocationAttendance.AddAttendance(attendance);
            rockContext.SaveChanges();

            //Add Person to Dictionary
            peopleList.Add( ppPerson.PersonName );
            repLinks.DataSource = peopleList;
            repLinks.DataBind();
            Session["peopleList"] = peopleList;

            //Clear Person field
            ppPerson.PersonId = null;
            ppPerson.PersonName = null;

            //Update Current Participants List
        }
All Usage Examples Of Rock.Model.AttendanceService::Get