Esempio n. 1
0
 protected async override Task OnInitializedAsync()
 {
     if (ContactId != Guid.Empty)
     {
         Contact = await ContactService.Get(ContactId);
     }
 }
Esempio n. 2
0
        public void setup()
        {
            //TODO looking to bogus for fake test data generation
            name = new ContactNameDTO
            {
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides"
            };

            address = new ContactAddressDTO
            {
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000"
            };

            phones = new List <ContactPhoneDTO>();
            ContactPhoneDTO phoneDTO = new ContactPhoneDTO
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phones.Add(phoneDTO);


            contactResponseDTO = new ContactResponseDTO
            {
                Id      = 1,
                name    = name,
                address = address,
                phone   = phones,
                email   = "*****@*****.**"
            };

            phoneEntities = new List <PhoneEntity>();
            PhoneEntity phone = new PhoneEntity
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phoneEntities.Add(phone);
            contactsEntity = new ContactsEntity
            {
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides",
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000",
                phones = phoneEntities,
                email  = "*****@*****.**"
            };
        }
Esempio n. 3
0
        public async Task <ContactResponseDTO> Edit(ContactResponseDTO contact)
        {
            var contactJson = new StringContent(JsonSerializer.Serialize(contact), Encoding.UTF8, "application/json");
            var response    = await _httpClient.PutAsync("api/Contacts", contactJson);

            if (response.IsSuccessStatusCode)
            {
                return(await JsonSerializer.DeserializeAsync <ContactResponseDTO>(await response.Content.ReadAsStreamAsync()));
            }
            return(null);
        }
Esempio n. 4
0
        public ContactResponseDTO Insert(ContactRequestDTO contact)
        {
            //TODO need to rethink for bad request submission -
            //is it even possible to send a bad request currently? (no integer id)
            ContactsEntity contactsEntity = _contactsMapper.convertRequestToEntity(contact);

            var id = _contactsRepo.Insert(contactsEntity);

            var foundInsert = _contactsRepo.FindOne(id);

            ContactResponseDTO contactResponseDTO = _contactsMapper.convertEntityToDTO(foundInsert);

            return(contactResponseDTO);
        }
Esempio n. 5
0
        public ContactResponseDTO convertEntityToDTO(ContactsEntity contactsEntity)
        {
            ContactAddressDTO address = new ContactAddressDTO
            {
                state  = contactsEntity.state,
                street = contactsEntity.street,
                city   = contactsEntity.city,
                zip    = contactsEntity.zip
            };

            ContactNameDTO name = new ContactNameDTO
            {
                first  = contactsEntity.first,
                middle = contactsEntity.middle,
                last   = contactsEntity.last
            };


            List <ContactPhoneDTO> phones = new List <ContactPhoneDTO>();

            foreach (PhoneEntity phone in contactsEntity.phones)
            {
                ContactPhoneDTO phoneDTO = new ContactPhoneDTO
                {
                    type   = phone.type,
                    number = phone.number
                };

                phones.Add(phoneDTO);
            }


            ContactResponseDTO response = new ContactResponseDTO
            {
                Id      = contactsEntity.Id,
                name    = name,
                address = address,
                phone   = phones,
                email   = contactsEntity.email
            };


            return(response);
        }
Esempio n. 6
0
        public IEnumerable <ContactResponseDTO> FindAll()
        {
            IEnumerable <ContactsEntity> contacts = _contactsRepo.FindAll();

            if (contacts.Count() == 0)
            {
                return(null);
            }

            List <ContactResponseDTO> contactResponse = new List <ContactResponseDTO>();

            foreach (ContactsEntity contact in contacts)
            {
                ContactResponseDTO contactResponseDTO = _contactsMapper.convertEntityToDTO(contact);
                contactResponse.Add(contactResponseDTO);
            }

            return(contactResponse);
        }