Exemple #1
0
        /// <summary>
        /// Gets Person information
        /// </summary>
        /// <param name="id">ID of the Person</param>
        /// <param name="person">Person instance to be populated</param>
        /// <param name="settings">Object containing Data Fetch settings</param>
        /// <returns>Person instance containing retreived information</returns>
        public Person GetPerson(long id, Person person, PersonDataFetchSettings settings)
        {
            GetPersonDetailsRequest request = new GetPersonDetailsRequest {
                ID = id, Settings = settings
            };
            GetPersonDetailsResponse response = jmAppClientProvider.CallAction <GetPersonDetailsResponse>(ActionNameConstants.GetPersonDetails, request);

            return(response.Person);
        }
Exemple #2
0
        public void ExecuteAction(IServiceProvider serviceProvider, ref object request, ref BaseResponse response)
        {
            GetPersonDetailsRequest  requestMessage  = request as GetPersonDetailsRequest;
            GetPersonDetailsResponse responseMessage = response as GetPersonDetailsResponse;

            IIMDbDataProvider imdbDataProvider = serviceProvider.GetRequiredService <IIMDbDataProvider>();

            responseMessage.Person = imdbDataProvider.GetPerson(requestMessage.ID, requestMessage.Settings);
        }
Exemple #3
0
 public ActionResult <GetPersonDetailsResponse> GetPersonDetails([FromQuery] GetPersonDetailsRequest request)
 {
     return(_personService.GetPersonDetails(request));
 }
        public GetPersonDetailsResponse GetPersonDetails(GetPersonDetailsRequest request)
        {
            try
            {
                var personDetails = _db.Persons.AsNoTracking()
                                    .Include(p => p.PersonPhones).AsNoTracking()
                                    .Include(rp => rp.RelatedPersons).AsNoTracking()
                                    .Where(t => t.Id == request.PersonId)
                                    .FirstOrDefault();

                var relatedPersonIds     = personDetails.RelatedPersons.Select(t => t.RelatedPersonId).ToList();
                var relatedPersonDetails = _db.Persons.AsNoTracking()
                                           .Include(p => p.PersonPhones).AsNoTracking()
                                           .Where(t => relatedPersonIds.Contains(t.Id))
                                           .ToList();

                var result = new PersonDetailsBaseModel
                {
                    PersonId       = personDetails.Id,
                    Fname          = personDetails.Fname,
                    Lname          = personDetails.Lname,
                    PersonalNumber = personDetails.PersonalNumber,
                    BirthDate      = personDetails.BirthDate,
                    GenderId       = personDetails.GenderId,
                    CityId         = personDetails.CityId,
                    Image          = !string.IsNullOrEmpty(personDetails.ImagePatch) ? File.ReadAllBytes(personDetails.ImagePatch) : null, //new byte[] { },

                    PersonPhones = personDetails.PersonPhones.Select(p => new PersonPhoneModel
                    {
                        Id          = p.Id,
                        PersonId    = p.PersonId,
                        PhoneNumber = p.PhoneNumber,
                        PhoneType   = ((PhoneType)p.PhoneTypeId).ToString()
                    }).ToList(),

                    RelatedPersons = relatedPersonDetails.Select(t => new PersonDetailsBaseModel
                    {
                        PersonId       = t.Id,
                        Fname          = t.Fname,
                        Lname          = t.Lname,
                        PersonalNumber = t.PersonalNumber,
                        BirthDate      = t.BirthDate,
                        GenderId       = t.GenderId,
                        CityId         = t.CityId,
                        Image          = !string.IsNullOrEmpty(t.ImagePatch) ? File.ReadAllBytes(t.ImagePatch) : null, //new byte[] { },

                        PersonPhones = t.PersonPhones.Select(p => new PersonPhoneModel
                        {
                            Id          = p.Id,
                            PersonId    = p.PersonId,
                            PhoneNumber = p.PhoneNumber,
                            PhoneType   = ((PhoneType)p.PhoneTypeId).ToString()
                        }).ToList()
                    }).ToList()
                };

                return(Success(new GetPersonDetailsResponse()
                {
                    PersonDetails = result
                }));
            }
            catch (Exception ex)
            {
                return(Error(new GetPersonDetailsResponse(), RsStrings.GetPersonDetailsUnexpectedException));
            }
        }