private static Person LogicPersonFromDbPerson(Data.Model.Person dbPerson)
 {
     return(new Person
     {
         FirstName = dbPerson.FirstName,
         LastName = dbPerson.LastName,
         BirthDate = dbPerson.BirthDate,
         DeathDate = dbPerson.DeathDate
     });
 }
Esempio n. 2
0
        /// <summary>
        /// Check if the person is in the dictionary, if not, check if the person
        /// is in the scene (checking by the name), if yes, add it to the dictionary,
        /// if not, create a new person and adds it to the scene and dictionary
        /// </summary>
        /// <param name="bodyTrackingId">The kinect body tracking identifier.</param>
        public void CheckIfExistsPerson(ulong bodyTrackingId)
        {
            if (!PersonsId.ContainsKey(bodyTrackingId))
            {
                bool   isPersonInScene = false;
                string personName      = "Kinect" + bodyTrackingId;
                var    personsInScene  = _dataAccessFacade.GetSceneInUseAccess()?.GetScene()?.PersonsInScene;
                foreach (var personInScene in personsInScene)
                {
                    string name = personInScene?.Person?.Name;
                    if (!ReferenceEquals(null, name) && name.Equals(personName))
                    {
                        PersonsId[bodyTrackingId] = personInScene.Person;
                        isPersonInScene           = true;
                        break;
                    }
                }
                if (!isPersonInScene)
                {
                    var newPerson = new Data.Model.Person()
                    {
                        Name       = personName,
                        Photo      = null,
                        Birthday   = null,
                        Sex        = null,
                        TrackingId = (long)bodyTrackingId
                    };
                    var pis = new Data.Model.PersonInScene()
                    {
                        Person = newPerson,
                        Scene  = _dataAccessFacade.GetSceneInUseAccess()?.GetScene()
                    };
                    _dataAccessFacade.GetSceneInUseAccess()?.GetScene().PersonsInScene.Add(pis);
                    PersonsId[bodyTrackingId] = newPerson;

                    /*
                     * //this writes to the database directly
                     * var newPerson = _dataAccessFacade.GetPersonAccess().Add(personName, null, null, null, (long)bodyTrackingId);
                     * PersonsId[bodyTrackingId] = newPerson.PersonId;
                     * _dataAccessFacade.GetPersonAccess().AddToScene(newPerson, _dataAccessFacade.GetSceneInUseAccess()?.GetScene());
                     */
                }
            }
        }