Example #1
0
        public ContactsEntity convertRequestToEntity(ContactRequestDTO contact)
        {
            List <PhoneEntity> phones = new List <PhoneEntity>();

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

                phones.Add(phoneEntity);
            }

            ContactsEntity contactEntity = new ContactsEntity
            {
                first  = contact.name.first,
                middle = contact.name.middle,
                last   = contact.name.last,
                state  = contact.address.state,
                street = contact.address.street,
                city   = contact.address.city,
                zip    = contact.address.zip,
                phones = phones,
                email  = contact.email
            };

            return(contactEntity);
        }
Example #2
0
        public async Task <bool> SaveContact(ContactsEntity contactModel)
        {
            if (_contactsEntity != null)
            {
                ContactsEntity contact = await _contactsEntity.Where(x => x.ContactId == contactModel.ContactId).FirstOrDefaultAsync();

                if (contact == null)
                {
                    contact = new ContactsEntity()
                    {
                        FirstName = contactModel.FirstName,
                        LastName  = contactModel.LastName,
                        Email     = contactModel.Email,
                        Phone     = contactModel.Phone
                    };

                    _dbContext.Add(contact);
                }
                else
                {
                    contact.FirstName = contactModel.FirstName;
                    contact.LastName  = contactModel.LastName;
                    contact.Email     = contactModel.Email;
                    contact.Phone     = contactModel.Phone;
                }

                return(await _dbContext.SaveChangesAsync() >= 1);
            }

            return(false);
        }
Example #3
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  = "*****@*****.**"
            };
        }
Example #4
0
 /// <summary> setups the sync logic for member _contacts</summary>
 /// <param name="relatedEntity">Instance to set as the related entity of type entityType</param>
 private void SetupSyncContacts(IEntity2 relatedEntity)
 {
     if (_contacts != relatedEntity)
     {
         DesetupSyncContacts(true, true);
         _contacts = (ContactsEntity)relatedEntity;
         base.PerformSetupSyncRelatedEntity(_contacts, new PropertyChangedEventHandler(OnContactsPropertyChanged), "Contacts", ContactFranchiseeAccessEntity.Relations.ContactsEntityUsingContactId, true, new string[] {  });
     }
 }
Example #5
0
        /// <summary> Initializes the class members</summary>
        protected virtual void InitClassMembers()
        {
            _contacts = null;

            PerformDependencyInjection();

            // __LLBLGENPRO_USER_CODE_REGION_START InitClassMembers
            // __LLBLGENPRO_USER_CODE_REGION_END
            OnInitClassMembersComplete();
        }
Example #6
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);
        }
Example #7
0
        public ContactResponseDTO FindOne(int id)
        {
            ContactsEntity     contactsEntity = _contactsRepo.FindOne(id);
            ContactResponseDTO contactResponseDTO;

            if (contactsEntity != null)
            {
                contactResponseDTO = _contactsMapper.convertEntityToDTO(contactsEntity);

                return(contactResponseDTO);
            }

            return(null);
        }
Example #8
0
 public Contact CreateContact(ContactsEntity contactsEntity)
 {
     return(new Contact(contactsEntity.ContactId)
     {
         Name = new Name(contactsEntity.FirstName, contactsEntity.MiddleName, contactsEntity.LastName),
         Email = _emailFactory.CreateEmail(contactsEntity.Email),
         HomePhoneNumber =
             _phoneNumberFactory.CreatePhoneNumber(contactsEntity.PhoneHome, PhoneNumberType.Home),
         MobilePhoneNumber =
             _phoneNumberFactory.CreatePhoneNumber(contactsEntity.PhoneCell, PhoneNumberType.Mobile),
         OfficePhoneNumber =
             _phoneNumberFactory.CreatePhoneNumber(contactsEntity.PhoneOffice, PhoneNumberType.Office),
         OfficePhoneExtn = contactsEntity.PhoneOfficeExtension
     });
 }
Example #9
0
        public async Task <bool> DeleteContact(int contactId)
        {
            if (_contactsEntity != null)
            {
                ContactsEntity contact = _contactsEntity.Where(x => x.ContactId == contactId).FirstOrDefault();

                if (contact != null)
                {
                    _dbContext.Remove(contact);
                }

                return(await _dbContext.SaveChangesAsync() >= 1);
            }

            return(false);
        }
Example #10
0
        protected ContactNotesEntity(SerializationInfo info, StreamingContext context) : base(info, context)
        {
            if (SerializationHelper.Optimization != SerializationOptimization.Fast)
            {
                _contacts = (ContactsEntity)info.GetValue("_contacts", typeof(ContactsEntity));
                if (_contacts != null)
                {
                    _contacts.AfterSave += new EventHandler(OnEntityAfterSave);
                }

                base.FixupDeserialization(FieldInfoProviderSingleton.GetInstance());
            }

            // __LLBLGENPRO_USER_CODE_REGION_START DeserializationConstructor
            // __LLBLGENPRO_USER_CODE_REGION_END
        }
Example #11
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);
        }
Example #12
0
        public void setup()
        {
            phoneEntities = new List <PhoneEntity>();
            PhoneEntity phone = new PhoneEntity
            {
                type   = "mobile",
                number = "100-100-100"
            };

            phoneEntities.Add(phone);
            contactsEntity = new ContactsEntity
            {
                Id     = 1,
                first  = "Paul",
                middle = "Muad Dib",
                last   = "Atreides",
                state  = "Arrakis",
                city   = "Sietch Tabr",
                street = "100 sietch lane",
                zip    = "10000",
                phones = phoneEntities,
                email  = "*****@*****.**"
            };
        }
Example #13
0
        public async Task <ContactsModel> ContactsGetById(int Id)
        {
            ContactsEntity entites = await GetSingleOrDefaultAsync <ContactsEntity>(s => s.Id == Id);

            return(Mapper.Map <ContactsEntity, ContactsModel>(entites));
        }
Example #14
0
 /// <summary> Removes the sync logic for member _contacts</summary>
 /// <param name="signalRelatedEntity">If set to true, it will call the related entity's UnsetRelatedEntity method</param>
 /// <param name="resetFKFields">if set to true it will also reset the FK fields pointing to the related entity</param>
 private void DesetupSyncContacts(bool signalRelatedEntity, bool resetFKFields)
 {
     base.PerformDesetupSyncRelatedEntity(_contacts, new PropertyChangedEventHandler(OnContactsPropertyChanged), "Contacts", ContactFranchiseeAccessEntity.Relations.ContactsEntityUsingContactId, true, signalRelatedEntity, "ContactFranchiseeAccess", resetFKFields, new int[] { (int)ContactFranchiseeAccessFieldIndex.ContactId });
     _contacts = null;
 }
Example #15
0
 public bool Update(ContactsEntity contact)
 {
     return(_liteDb.GetCollection <ContactsEntity>("Contact")
            .Update(contact));
 }
Example #16
0
 public int Insert(ContactsEntity contact)
 {
     return(_liteDb.GetCollection <ContactsEntity>("Contact")
            .Insert(contact));
 }