static async Task <Tuple <List <Face>, List <User> > > FaceIdentification(FaceIdentificationContext appContext)
        {
            var IReturn = new Tuple <List <Face>, List <User> >(new List <Face>(), new List <User>());

            if (appContext.ImageUrl == null)
            {
                throw new ErrorMsg("imageDoesntExist", "image not found maybe link is not attached ");
            }
            List <Face> Faces = await FaceService.FaceDetection(appContext.ImageUrl);

            string personGroupId = MappingService.GetFromMapping(appContext.AppID, appContext.Context.Id); //get from mapping

            if (MappingService.IsPersonGroupExist(appContext.AppID, appContext.Context.Id))                //check if context has group ? get groupID : return detection in faces and emty users
            {
                IReturn = await FaceService.Identify(personGroupId, Faces, appContext);
            }
            IReturn = Tuple.Create(Faces, new List <User>());
            StorageService.uploadImageAsync(appContext.ImageUrl, ImageType.Url, appContext.AppID, appContext.Context.Id);
            return(IReturn);
        }
        public async static Task Register(FaceRegistrationContext appContext) //input : group name, persons names
        {
            string GroupId;

            if (MappingService.IsPersonGroupExist(appContext.AppId, appContext.Context.Id))
            {
                GroupId = MappingService.GetFromMapping(appContext.AppId, appContext.Context.Id);
            }
            else
            {//creat group
                Guid g = Guid.NewGuid();
                GroupId = g.ToString();
                await FaceService.CreatePersonGroup(GroupId, appContext.Context.Name);

                await MappingService.InsertNewPersonGroup(appContext.AppId, appContext.Context.Id, GroupId);
            }
            //creat n persons
            string ImgURL = StorageService.GetImageUrl(appContext.AppId, appContext.Context.Id); //mapping get img using appid,contextid

            if (ImgURL == "")
            {
                throw new ErrorMsg("InvalidURL", "Failed to download from target server. Remote server error returned.");
            }
            foreach (User user in appContext.Users)
            {
                string PersonId;
                if (MappingService.GetFromMapping(appContext.AppId + "-" + appContext.Context.Id, user.Id) != "")
                {
                    PersonId = MappingService.GetFromMapping(appContext.AppId + "-" + appContext.Context.Id, user.Id);
                }
                else
                {
                    //create person
                    PersonId = await FaceService.CreatePerson(GroupId, user.Name); //temp names

                    if (PersonId == "")
                    {
                        throw new ErrorMsg("PersonCreationFailed", "Failed to Create person. maybe it reached the limit or connection error");
                    }
                    //Console.WriteLine("person " + user.Name + " id: " + PersonId);
                    //insert person
                    IList <TableResult> TempResult = await MappingService.InsertNewPerson(appContext.AppId, appContext.Context.Id, PersonId, user.Id);

                    foreach (TableResult Result in TempResult)
                    {
                        if (!Result.HttpStatusCode.Equals(HttpStatusCode.OK))
                        {
                            throw new ErrorMsg("PersonAdditionToStorageFailed", "Failed to Store person In Azure Table");
                        }
                    }
                    //add face to person

                    await FaceService.AddFaceToPerson(GroupId, PersonId, ImgURL, user.Face.Location);//add last image
                }

                //train person group
                await FaceService.TrainPersonGroup(GroupId);

                //check training status
                await FaceService.GetTrainingStatus(GroupId);
            }
        }