/// <summary>
        /// Updates a ContactDetails
        /// </summary>
        /// <param name="contactId"></param>
        /// <param name="contactDetailsEntity"></param>
        /// <returns></returns>
        public bool UpdateContactDetails(int contactId, ContactDetailsEntity contactDetailsEntity)
        {
            var success = false;

            if (contactDetailsEntity != null)
            {
                using (var scope = new TransactionScope())
                {
                    var contactDetail = _unitOfWork.ContactDetailRepository.GetByID(contactId);
                    if (contactDetail != null)
                    {
                        contactDetail.FirstName   = contactDetailsEntity.FirstName;
                        contactDetail.LastName    = contactDetailsEntity.LastName;
                        contactDetail.Email       = contactDetailsEntity.Email;
                        contactDetail.PhoneNumber = contactDetailsEntity.PhoneNumber;
                        contactDetail.Status      = contactDetailsEntity.Status;
                        _unitOfWork.ContactDetailRepository.Update(contactDetail);
                        _unitOfWork.Save();
                        scope.Complete();
                        success = true;
                    }
                }
            }
            return(success);
        }
 public ActionResult Edit(ContactDetailsEntity contactDetail)
 {
     if (ModelState.IsValid)
     {
         _contactDetailsServices.UpdateContactDetails(contactDetail.ContactId, contactDetail);
         return(RedirectToAction("Index"));
     }
     return(View(contactDetail));
 }
        public async Task <ContactDetails> CreateContact(ContactDetailsEntity contactDetails)
        {
            _logger.LogDebug($"Calling IDynamoDBContext.SaveAsync for targetId {contactDetails.TargetId} and id {contactDetails.Id}");

            contactDetails.LastModified = DateTime.UtcNow;
            await _dynamoDbContext.SaveAsync(contactDetails).ConfigureAwait(false);

            return(contactDetails.ToDomain());
        }
 public static ContactDetails ToDomain(this ContactDetailsEntity databaseEntity)
 {
     return(new ContactDetails
     {
         Id = databaseEntity.Id,
         TargetId = databaseEntity.TargetId,
         TargetType = databaseEntity.TargetType,
         ContactInformation = databaseEntity.ContactInformation,
         SourceServiceArea = databaseEntity.SourceServiceArea,
         CreatedBy = databaseEntity.CreatedBy,
         IsActive = databaseEntity.IsActive,
         RecordValidUntil = databaseEntity.RecordValidUntil,
         LastModified = databaseEntity.LastModified
     });
 }
        // GET: ContactDetails/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            int contsatId = (int)id;
            ContactDetailsEntity contactDetail = _contactDetailsServices.GetContactDetailsById(contsatId);

            if (contactDetail == null)
            {
                return(HttpNotFound());
            }
            return(View(contactDetail));
        }
        public static ContactDetailsEntity ToDatabase(this ContactDetails domain)
        {
            var entity = new ContactDetailsEntity
            {
                Id                 = domain.Id,
                TargetId           = domain.TargetId,
                TargetType         = domain.TargetType,
                ContactInformation = domain.ContactInformation,
                SourceServiceArea  = domain.SourceServiceArea,
                CreatedBy          = domain.CreatedBy,
                IsActive           = domain.IsActive,
                RecordValidUntil   = domain.RecordValidUntil,
                LastModified       = domain.LastModified
            };

            if (domain.ContactInformation.ContactType == V1.Domain.ContactType.address)
            {
                entity.ContactInformation.Value = FormatSingleLineAddress(domain.ContactInformation.AddressExtended);
            }

            return(entity);
        }
        public static ContactDetails ToDomain(this ContactDetailsEntity databaseEntity)
        {
            var contactInformation = databaseEntity.ContactInformation;

            if (contactInformation.ContactType == V1.Domain.ContactType.address &&
                string.IsNullOrEmpty(contactInformation.AddressExtended.AddressLine1))
            {
                // only required for addresses created using v1 endpoint
                contactInformation.AddressExtended.AddressLine1 = contactInformation.Value;
            }

            return(new ContactDetails
            {
                Id = databaseEntity.Id,
                TargetId = databaseEntity.TargetId,
                TargetType = databaseEntity.TargetType,
                ContactInformation = contactInformation,
                SourceServiceArea = databaseEntity.SourceServiceArea,
                CreatedBy = databaseEntity.CreatedBy,
                IsActive = databaseEntity.IsActive,
                RecordValidUntil = databaseEntity.RecordValidUntil,
                LastModified = databaseEntity.LastModified
            });
        }
 private async Task InsertDataIntoDynamoDB(ContactDetailsEntity entity)
 {
     await _dbFixture.SaveEntityAsync <ContactDetailsEntity>(entity).ConfigureAwait(false);
 }