예제 #1
0
        public async Task <int> AddAsync(CreateContactRecordInput input)
        {
            var existContactRecord = await _contactRecordRepository.GetByEmailAsync(input.Email);

            //TO-DO: Create own Exception
            if (existContactRecord != null)
            {
                throw new ContactRecordExistsException("ContactRecord alerady exists");
            }

            //TO-DO: Use Automapper
            var address       = new Core.ValueObjects.Address(input.Address.State, input.Address.City, input.Address.ZipCode, input.Address.Street, input.Address.Number);
            var phoneNumber   = new Core.ValueObjects.PhoneNumber(input.PhoneNumber.PersonalNumber, input.PhoneNumber.WorkNumber);
            var contactRecord = new Core.Entities.ContactRecord(input.Name, input.Company, input.ProfileImagePath, input.Email, input.BirthDate, phoneNumber, address);

            await _contactRecordRepository.AddAsync(contactRecord);

            return(await _contactRecordRepository.UnitOfWork.SaveChangesAsync());
        }
예제 #2
0
 public void Update(Core.Entities.ContactRecord contactRecord)
 {
     _context.ContactRecord.Update(contactRecord);
 }
예제 #3
0
 public void Delete(Core.Entities.ContactRecord contactRecord)
 {
     _context.ContactRecord.Remove(contactRecord);
 }
예제 #4
0
 public async Task AddAsync(Core.Entities.ContactRecord contactRecord)
 {
     await _context.ContactRecord.AddAsync(contactRecord);
 }