public async Task <Logic.Objects.Profile> GetProfileByIDAsync(Guid clientID) { Logic.Objects.Profile logicProfile = await santaContext.Clients .Select(client => new Logic.Objects.Profile() { clientID = client.ClientId, clientName = client.ClientName, nickname = client.Nickname, email = client.Email, address = new Address { addressLineOne = client.AddressLine1, addressLineTwo = client.AddressLine2, city = client.City, country = client.Country, state = client.State, postalCode = client.PostalCode }, responses = client.SurveyResponses.Select(surveyResponse => new Response() { surveyResponseID = surveyResponse.SurveyResponseId, clientID = surveyResponse.ClientId, surveyID = surveyResponse.SurveyId, surveyOptionID = surveyResponse.SurveyOptionId, responseText = surveyResponse.ResponseText, responseEvent = Mapper.MapEvent(surveyResponse.Survey.EventType), surveyQuestion = Mapper.MapQuestion(surveyResponse.SurveyQuestion) }).ToList(), editable = client.ClientRelationXrefRecipientClients.Count > 0 ? false : true }).FirstOrDefaultAsync(c => c.clientID == clientID); return(logicProfile); }
public static Profile MapProfile(Entities.Client contextClient) { Logic.Objects.Profile logicProfile = new Logic.Objects.Profile() { clientID = contextClient.ClientId, clientName = contextClient.ClientName, nickname = contextClient.Nickname, email = contextClient.Email, address = new Address { addressLineOne = contextClient.AddressLine1, addressLineTwo = contextClient.AddressLine2, city = contextClient.City, country = contextClient.Country, state = contextClient.State, postalCode = contextClient.PostalCode }, //assignments = contextClient.ClientRelationXrefSenderClient.Select(s => Mapper.MapProfileRecipient(s, s.RecipientClient)).OrderBy(pr => pr.recipientClient.clientNickname).ToList(), responses = contextClient.SurveyResponse.Select(Mapper.MapResponse).ToList(), editable = contextClient.ClientRelationXrefRecipientClient.Count > 0 ? false : true }; return(logicProfile); }