Example #1
0
        public static async Task <PersonOperationStatus> CreatePerson(string strPersonGroupId, string strPersonName)
        {
            PersonOperationStatus status = new PersonOperationStatus();
            ////////////////////////////////////////////////////////////////////////////////////
            string strUserData = "";

            try
            {
                ////////////////////////////////////////////////////////////////////////////////////
                status.AttemptedDatabaseOperation = true;
                MyPerson person = new MyPerson();
                using (var db = new Facial_Recognition_Library.Data.LiveEduFaceModel())
                {
                    status.CompletedDatabaseOperation = MyPerson.AddPerson(db, ref person);
                }
                ////////////////////////////////////////////////////////////////////////////////////
                status.AttemptedAPIOperation = true;
                await ProjectOxfordAPI.CreatePerson(strPersonGroupId, strPersonName, strUserData);

                status.CompletedAPIOperation = true;
                ////////////////////////////////////////////////////////////////////////////////////
            }
            catch (Exception e)
            {
                status.ReasonForFailure = $"Attempts made to update database and api failed : {e.Message}";
            }
            return(status);
        }
Example #2
0
        public static async Task <PersonOperationStatus> DeletePerson(string PersonGroupId, string personId = null)
        {
            bool rtnStatus = false;
            PersonOperationStatus status = new PersonOperationStatus();
            ////////////////////////////////////////////////////////////////////////////////////
            Guid uuidPersonGuid = Guid.Empty;

            ////////////////////////////////////////////////////////////////////////////////////
            status.AttemptedDatabaseOperation = true;
            try
            {
                using (var db = new Facial_Recognition_Library.Data.LiveEduFaceModel())
                {
                    status.CompletedDatabaseOperation = MyPerson.DeletePersonById(db, PersonGroupId, out uuidPersonGuid);
                }
                status.CompletedDatabaseOperation = true;
            }
            catch (Exception e)
            {
                status.ReasonForFailure += $"Failed to remove from database {e.Message} |";
            }

            ////////////////////////////////////////////////////////////////////////////////////
            status.AttemptedAPIOperation = true;
            try
            {
                await ProjectOxfordAPI.DeletePerson(PersonGroupId, uuidPersonGuid);

                status.CompletedAPIOperation = true;
            }
            catch (Exception e)
            {
                status.ReasonForFailure += $"Failed to remove from api {e.Message} |";
            }
            ////////////////////////////////////////////////////////////////////////////////////
            return(status);
        }