예제 #1
0
        public RegesteredPersonResult FetchAllUsers()
        {
            List <Person>          AllPersons = new List <Person>();
            RegesteredPersonResult result     = new RegesteredPersonResult();

            try
            {
                using (KodinetDbContext GetPersonContext = new KodinetDbContext())
                {
                    AllPersons = GetPersonContext.Person
                                 .ToList <Person>();
                }

                return(new RegesteredPersonResult()
                {
                    person = AllPersons,
                    Message = "Success",
                    StatusCode = 200
                });
            }
            catch (Exception)
            {
                throw;
            }
        }
예제 #2
0
        public async Task <RegesteredPersonResult> ValidateMember(Filters filters)
        {
            RegesteredPersonResult regesteredPersonResult = new RegesteredPersonResult();

            //Validation by Id
            if (filters.ValidationMethod == ValidationMethod.NationalId)
            {
                Person person = GetPerson(filters.Id);
                if (person != null)
                {
                    regesteredPersonResult.OnePerson  = person;
                    regesteredPersonResult.Message    = HttpStatusCode.OK.ToString();
                    regesteredPersonResult.StatusCode = (int)HttpStatusCode.OK;
                }
                else
                {
                    regesteredPersonResult.Message    = HttpStatusCode.NotFound.ToString();
                    regesteredPersonResult.StatusCode = (int)HttpStatusCode.NotFound;
                }
                return(regesteredPersonResult);
            }

            //Validation By fingerprint
            FingerprintValidationRequest request = new FingerprintValidationRequest()
            {
                Fingerprint = filters.FingerPrint
            };
            FingerprintValidationResult result = null;

            try
            {
                string response = await PostWorktoProcess("", request);

                if (response != null)
                {
                    result = JsonConvert.DeserializeObject <FingerprintValidationResult>(response);
                    if (result != null)
                    {
                        Models.Person registeredPersonResult = GetPerson(result.Identifier);
                        if (registeredPersonResult == null)
                        {
                            regesteredPersonResult = new RegesteredPersonResult {
                                Error = "Member not found", Message = "Member not Found", OnePerson = null, StatusCode = (int)HttpStatusCode.NotFound
                            };
                        }
                        else
                        {
                            regesteredPersonResult.StatusCode = (int)HttpStatusCode.OK;
                            regesteredPersonResult.OnePerson  = registeredPersonResult;
                            regesteredPersonResult.Message    = HttpStatusCode.OK.ToString();
                        }
                    }
                }
                else
                {
                    regesteredPersonResult.StatusCode = (int)HttpStatusCode.NotFound;

                    regesteredPersonResult.Message = HttpStatusCode.NotFound.ToString();
                }
            }
            catch (Exception ex)
            {
                regesteredPersonResult.Message    = HttpStatusCode.InternalServerError.ToString();
                regesteredPersonResult.StatusCode = (int)HttpStatusCode.InternalServerError;
                regesteredPersonResult.Error      = ex.Message;
                LogErrorOnFile(ex.Message);
                LogErrorOnFile(ex.StackTrace);
            }
            return(regesteredPersonResult);
        }