コード例 #1
0
        public Guid ImportPerson(string personId)
        {
            try
            {
                // getting person data from external data source
                var model = _facade.GetPerson(personId);

                // mapping received data to DB entity
                var entity = model.ToEntity(PersonStatusEnum.New);

                // persisting person data in database
                _repo.UpdateOrCreate(entity);

                if (new[] { PersonStatusEnum.New, PersonStatusEnum.Updated }.Contains(entity.Status))
                {
                    // sending a Queue service message that a given person imported/updated
                    var msqId = _messageQueue.Put(MSQ_QUEUE_NAME, new PersonUpdateMessage {
                        PersonId = entity.Id, Status = entity.Status
                    });

                    // updating status of the imported person in the local DB
                    _repo.SetPersonStatus(entity.Id, PersonStatusEnum.Published);
                }

                return(entity.Id);
            }
            catch (Exception ex)
            {
                throw new ImportException(ex.Message);
            }
        }