Example #1
0
        public MessageResponse UpdatePerson(UpdatePerson person, Application app)
        {
            MessageResponse messageResponse = null;
            string          messageXml      = string.Empty;

            using (var tr = new Tracer("LMS.Connector.CCM.Repositories.SoapRepository.UpdateAccount"))
            {
                try
                {
                    messageXml = person.Message?.SerializeToXmlString();
                    tr.Log($"UpdatePerson: BEFORE setting host values => {messageXml}");

                    tr.Log("UpdatePerson: Set Application-level host values ");
                    messageXml = HostValueTranslator.UpdateRequestWithHostValues(
                        messageXml,
                        app.HostValues.Where(hv => hv.Field1.StartsWith("UpdatePerson.")).ToList(),
                        person.Message?.HostValueParentNode
                        );
                    tr.Log($"UpdatePerson: AFTER Application-level host values => {messageXml}");

                    tr.Log("UpdatePerson: Calling ISoapRepository.ProcessMessage");
                    messageResponse = ProcessMessage(messageXml);
                }
                catch (Exception ex)
                {
                    // Handle serialization and host value translation exceptions here

                    tr.LogException(ex);
                    Utility.LogError(ex, "LMS.Connector.CCM.Repositories.SoapRepository.UpdatePerson");
                    throw;
                }
            }

            return(messageResponse);
        }
Example #2
0
        // This method will be called for each input received from the pipeline to this cmdlet; if no input is received, this method is not called
        protected override void ProcessRecord()
        {
            UpdatePerson person = GetInitUpdateModel();

            // Populate from student object if object was used.
            if (_contactCodeProvided)
            {
                person.ContactCode = ContactCode;
            }
            ;
            if (_titleProvided)
            {
                person.Title = Title;
            }
            ;
            if (_firstNameProvided)
            {
                person.FirstName = FirstName;
            }
            ;
            if (_middleNamesProvided)
            {
                person.MiddleNames = MiddleNames;
            }
            ;
            if (_lastNameProvided)
            {
                person.LastName = LastName;
            }
            ;
            if (_legalLastNameProvided)
            {
                person.LegalLastName = LegalLastName;
            }
            ;
            if (_preferredNameProvided)
            {
                person.PreferredName = PreferredName;
            }
            ;
            if (_genderCodeProvided)
            {
                person.GenderCode = GenderCode;
            }
            ;
            if (_crnProvided)
            {
                person.CRN = CRN;
            }
            ;
            if (_languageSpokenAtHomeCodeProvided)
            {
                person.LanguageSpokenAtHomeCode = LanguageSpokenAtHomeCode;
            }
            ;

            var response = SentralApiClient.Enrolments.UpdatePerson(person);

            WriteObject(response);
        }
Example #3
0
        public void TaskFailTest()
        {
            var task   = new UpdatePerson(EmptyDbContext, new FormattingService());
            var result = task.DoTask(null);

            Assert.IsFalse(result.Success);
            Assert.IsNotNull(result.Exception);
        }
Example #4
0
 public string GetLastUpdatedBy()
 {
     if (UpdatePersonID.HasValue)
     {
         return(UpdatePerson.GetFullNameFirstLast());
     }
     return(CreatePerson.GetFullNameFirstLast());
 }
Example #5
0
        public ActionResult <UpdatePersonResult> UpdatePerson(int accountId, UpdatePerson updatePerson)
        {
            var updatePersonDto = new UpdatePersonDto()
            {
                DOME_header = new R542a.domeHeaderDto()
                {
                    langue = "fr",
                    deviceTypeSpecified = true,
                    deviceType          = (int)DeviceType,
                    dateSpecified       = true,
                    date    = AuthentificationHelper.date,
                    version = AuthentificationHelper.version,
                },
                accountId          = accountId,
                accountIdSpecified = true,
                DOME_createPerson  = new R542a.CreatePersonInnerDto()
                {
                    personCivilityId          = (int?)updatePerson.PersonCivility ?? -1,
                    personCivilityIdSpecified = updatePerson.PersonCivility.HasValue,

                    personBirthDate          = (DateTime?)updatePerson.PersonBirthDate ?? DateTime.MinValue.Date,
                    personBirthDateSpecified = updatePerson.PersonBirthDate.HasValue,

                    personAddressComp1      = updatePerson.PersonAddressComp1,
                    personAddressComp2      = updatePerson.PersonAddressComp2,
                    personBirthName         = updatePerson.PersonBirthName,
                    personCedex             = updatePerson.PersonCedex,
                    personCityName          = updatePerson.PersonCityName,
                    personCityZipCode       = updatePerson.PersonCityZipCode,
                    personComment           = updatePerson.PersonComment,
                    personEmail1            = updatePerson.PersonEmail1,
                    personEmail2            = updatePerson.PersonEmail2,
                    personFirstName         = updatePerson.PersonFirstName,
                    personINSA              = updatePerson.PersonInsa,
                    personINSC              = updatePerson.PersonInsc,
                    personJob               = updatePerson.PersonJob,
                    personLastName          = updatePerson.PersonLastName,
                    personLieuDit           = updatePerson.PersonLieuDit,
                    personMobilePhoneNumber = updatePerson.PersonMobilePhoneNumber,
                    personNIR               = updatePerson.PersonNir,
                    personPhoneNumber       = updatePerson.PersonPhoneNumber,
                    personPostBox           = updatePerson.PersonPostBox,
                    personRoadName          = updatePerson.PersonRoadName,
                    personRoadNumber        = updatePerson.PersonRoadNumber,
                    personRoadType          = updatePerson.PersonRoadType,
                    personRPPS              = updatePerson.PersonRpps,
                    specialCriteria         = updatePerson.SpecialCriteria,
                }
            };
            var data = DomeCallSoap.UpdatePerson(updatePersonDto);

            if (data.statusId == 0)
            {
                return(new ActionResult <UpdatePersonResult>(true, new UpdatePersonResult(data)));
            }
            return(new ActionResult <UpdatePersonResult>(false, new UpdatePersonResult(data), new Message(MessageType.Error, data.statusErrorMessage)));
        }
 public IActionResult Put([FromBody] UpdatePerson updatePerson)
 {
     if (updatePerson == null)
     {
         return(Json(new { Message = "Server kon verzonden bericht niet correct lezen" }));
     }
     _service.UpdateDeelnemer(updatePerson);
     return(Ok());
 }
Example #7
0
        public UpdatePerson GetDto(LmsPerson lmsPerson)
        {
            var person = new UpdatePerson()
            {
                Message = GetMessage(lmsPerson)
            };

            return(person);
        }
        public IActionResult PutPerson(int id, UpdatePerson model)
        {
            var people = db.People.Find(id);

            people.InjectFrom(model);

            db.SaveChanges();

            return(Ok());
        }
Example #9
0
        public BaseResult UpdatePerson(LmsPerson lmsPerson)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.UpdatePersonBehavior.UpdatePerson"))
            {
                if (lmsPerson.Applicant != null)
                {
                    tr.Log($"UpdatePerson for ApplicantId {lmsPerson.Applicant.ApplicantId}, PersonNumber => {lmsPerson.Applicant.PersonNumber}");
                }
                else if (lmsPerson.AuthorizedUser != null)
                {
                    tr.Log($"UpdatePerson for AuthorizedUserId {lmsPerson.AuthorizedUser.AuthorizedUserId}, PersonNumber => {lmsPerson.AuthorizedUser.PersonNumber}");
                }

                tr.Log($"UpdatePerson _person null? => {_person == null}");
                if (_person == null)
                {
                    tr.Log("Call GetDto() to get new _person");
                    _person = GetDto(lmsPerson);
                }
                tr.LogObject(_person);

                try
                {
                    tr.Log("Calling ISoapRepository.UpdatePerson");
                    _messageResponse = _soapRepository.UpdatePerson(_person, _app);

                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");
                }
                catch (Exception ex)
                {
                    tr.LogException(ex);
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.UpdatePersonBehavior.UpdatePerson");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to call SOAP Repository UpdatePerson(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _person = null;
                }

                if (_messageResponse?.ResponseCode != "Success" && _messageResponse?.ErrorMessage?.Length > 0)
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, _messageResponse.ErrorMessage);

                    return(result);
                }
            }

            return(result);
        }
        public void UpdateDeelnemerTest()
        {
            //Assert
            var context      = Substitute.For <IDeelnemerContext>();
            var service      = Substitute.For <IDeelnemerService>();
            var controller   = new DeelnemerController(context, service);
            var updatePerson = new UpdatePerson();

            //Act
            var result = controller.Put(updatePerson);

            //Assert
            service.Received().UpdateDeelnemer(updatePerson);
            Assert.IsType <OkResult>(result);
        }
Example #11
0
        //Update
        public async Task <Person> Handle(UpdatePerson request, CancellationToken cancellationToken)
        {
            var person = await ctx.Persons.SingleOrDefaultAsync(V => V.Id == request.Id);

            if (person == null)
            {
                throw new Exception("Record does not exist");
            }

            person.FirstName = request.FirstName;
            person.Age       = request.Age;

            ctx.Persons.Update(person);
            await ctx.SaveChangesAsync();

            return(person);
        }
Example #12
0
        public void UpdatePatientFail()
        {
            var fakeId     = Guid.NewGuid().ToString();
            var domeClient = TestHelper.GetNewClient();

            var createPatient = new CreateBeneficiaire()
            {
                PersonCityName    = "Bron",
                PersonCityZipCode = "69500",
                PersonFirstName   = "FirstName" + fakeId,
                PersonLastName    = "LastName" + fakeId,
                PersonRoadName    = "rue edison",
                PersonEmail1      = "*****@*****.**"
            };


            var patient = domeClient.CreateBeneficiaire(createPatient);


            var beforeUpdate = domeClient.GetAccount(patient.Entity.AccountId).Entity.DOME_profileList.Single(profil => profil.profileId == patient.Entity.ProfileId);

            Assert.AreEqual(beforeUpdate.DOME_personData.personCityName, "Bron");
            Assert.AreEqual(beforeUpdate.DOME_personData.personCityZipCode, "69500");


            fakeId = Guid.NewGuid().ToString();

            var updatePerson = new UpdatePerson()
            {
                PersonCityName    = "Lyon",
                PersonCityZipCode = "69003",
                PersonFirstName   = "FirstName" + fakeId,
                PersonLastName    = "LastName" + fakeId,
                PersonRoadName    = "rue edison",
                PersonEmail1      = "*****@*****.**",
            };

            var entourage = domeClient.UpdatePerson(-1, updatePerson);

            Assert.IsFalse(entourage.Succeeded);

            var afterUpdate = domeClient.GetAccount(patient.Entity.AccountId).Entity.DOME_profileList.Single(profil => profil.profileId == patient.Entity.ProfileId);

            Assert.AreEqual(afterUpdate.DOME_personData.personCityName, "Bron");
            Assert.AreEqual(afterUpdate.DOME_personData.personCityZipCode, "69500");
        }
Example #13
0
        public async Task <IActionResult> SaveUpdatePerson(UpdatePerson updatePerson)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    await _personRepository.UpdatePerson(_mapper.Map <Person>(updatePerson));

                    return(RedirectToAction(nameof(Index)));
                }
            } catch (Exception)
            {
                return(BadRequest());
            }

            return(View("EditPerson", updatePerson));
        }
Example #14
0
        private UpdatePerson.Response UpdatePersonHandler(UpdatePerson command)
        {
            ITracer tracer = platform.Tracer;

            tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Update Person Start...");
            try
            {
                var entity = platform.GetEntity <IPerson>(command.Id);
                if (entity == null)
                {
                    return(new UpdatePerson.Response {
                        Error = new ExecutionError(-1010, string.Format("[{0}]已经不存在,不允许更新", command.FirstName))
                    });
                }
                else
                {
                    var existentity = platform.Query <IPerson>().FirstOrDefault(x => x.FirstName == command.FirstName && x.LastName == command.LastName);
                    if (existentity != null)
                    {
                        if (!existentity.Id.Equals(command.Id))
                        {
                            return(new UpdatePerson.Response {
                                Error = new ExecutionError(-1010, string.Format("[{0}]+[{1}]已经存在,不允许更新", command.FirstName, command.LastName))
                            });
                        }
                    }
                    entity.FirstName = command.FirstName;
                    entity.LastName  = command.LastName;
                    entity.IsActive  = command.IsActive;
                    entity.Birthday  = command.Birthday;
                    entity.Age       = command.Age;
                    entity.Sex       = command.Sex;
                }
                platform.Submit(entity);
                tracer.Write("Siemens-SimaticIT-Trace-Custom", Category.Informational, "Update Person End...");
                return(new UpdatePerson.Response {
                });
            }
            catch (Exception ex)
            {
                return(new UpdatePerson.Response {
                    Error = new ExecutionError(-1010, string.Format("[{0}]更新发生异常,异常信息是:{1}", command.FirstName, ex.Message))
                });
            }
        }
Example #15
0
        public async Task <Person> Handle(UpdatePerson request, CancellationToken cancellationToken)
        {
            var person = await ctx.Persons.SingleOrDefaultAsync(v => v.Id == request.Id);

            if (person == null)
            {
                throw new ApiException("Record does not exist");
            }

            person.Age       = request.Age;
            person.FirstName = request.FirstName;
            ctx.Persons.Update(person);
            await ctx.SaveChangesAsync();

            // await _bus.Publish<Message>(new { Value = person.Id.ToString() });

            return(person);
        }
Example #16
0
        //[Authorize]
        //public IActionResult Edit(int id)
        //{
        //    var model = _service.GetPersonForUpdate(id);
        //    if (model == null)
        //    {
        //        return NotFound();
        //    }
        //    return View(model);
        //}

        //private IActionResult NotFound()
        //{
        //    throw new NotImplementedException();
        //}

        //[HttpPost]
        //public IActionResult Edit(UpdatePerson command)
        //{
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            _service.UpdatePerson(command);
        //            return RedirectToAction(nameof(View), new { id = command.Id });
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        ModelState.AddModelError(
        //            string.Empty,
        //            "An error occured saving the person"
        //            );
        //    }

        //    return View(command);
        //}

        //[HttpPost, Authorize]
        //public IActionResult Create(CreatePerson command)
        //{
        //    try
        //    {
        //        if (ModelState.IsValid)
        //        {
        //            var id = _service.CreatePerson(command);
        //            return RedirectToAction(nameof(View), new { id = id });
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        ModelState.AddModelError(
        //            string.Empty,
        //            "An error occured saving the person"
        //            );
        //    }
        //    return View(command);
        //}

        public void UpdatePerson(UpdatePerson cmd)
        {
            var person = _personContext.Persons.Find(cmd.Id);

            if (person == null)
            {
                _logger.LogError("This is no person with ID: ", cmd.Id);
                throw new Exception("Unable to find the person");
            }
            if (person.IsDeleted)
            {
                _logger.LogError("Unable to update deleted person with ID: ", cmd.Id);
                throw new Exception("Unable to update a deleted person");
            }

            _logger.LogInformation("Getting information for person with ID: ", cmd.Id);
            cmd.UpdatePersons(person);
            _personContext.SaveChanges();
        }
        /// <summary>
        /// Scenario: User want to update a Home For Sale as Sold with a Buyer and possibly new Agent and/or RECo.
        /// </summary>
        private void Case_HomeSold()
        {
            //  HOME INFO
            LoadHomeInfoFields();

            //  BUYER INFO
            BuyerUpdated = false;
            BuyerNameTextbox.IsReadOnly         = true;
            BuyerCreditRatingTextbox.IsReadOnly = true;
            ExistingBuyersCombobox.IsEnabled    = true;
            AddNewBuyerButton.Visibility        = Visibility.Visible;
            AddNewBuyerButton.IsEnabled         = true;
            LoadBuyersCombobox();

            //  HOMESALE INFO
            HomesaleUpdated = false;
            forSaleHomeIdTextbox.IsReadOnly = true;
            forSaleHomeIdTextbox.Text       = UpdateHomeSale.HomeID.ToString();
            hfsSoldDatePicker.IsEnabled     = true;
            hfsSoldDatePicker.BlackoutDates.Add(new CalendarDateRange(DateTime.MinValue, DateTime.Today.AddDays(-5)));
            hfsSoldDatePicker.SelectedDate   = DateTime.Today;
            hfsSaleAmountTextbox.Text        = UpdateHomeSale.SaleAmount.ToString();
            hfsMarketDatePicker.SelectedDate = UpdateHomeSale.MarketDate;
            hfsMarketDatePicker.IsEnabled    = false;

            //  AGENT INFO
            AgentNameTextbox.IsReadOnly = true;
            UpdateAgentCompanyNameTextbox.IsReadOnly = true;
            UpdateAgentCommissionTextbox.IsReadOnly  = true;
            updateChangedAgentFieldsButton.IsEnabled = true;
            AddNewAgentButton.Visibility             = Visibility.Hidden;
            AddNewAgentButton.IsEnabled = false;

            if (UpdateAgent != null)
            {
                UpdateAgentCommissionTextbox.Text  = UpdateAgent.CommissionPercent.ToString() ?? string.Empty;
                UpdateAgentCompanyNameTextbox.Text = UpdateReco.CompanyName.ToString() ?? "Agent no longer active";
                AgentNameTextbox.Text = UpdatePerson.GetFirstAndLastName();
            }

            LoadAgentsCombobox(true);
        }
Example #18
0
        public void TaskSuccessTest()
        {
            var testPerson      = TestsModel.Person;
            var addPersonTask   = new AddPerson(DbContext, new FormattingService());
            var addPersonResult = addPersonTask.DoTask(testPerson);

            Assert.IsTrue(addPersonResult.Success);
            Assert.IsNull(addPersonResult.Exception);

            var task     = new UpdatePerson(DbContext, new FormattingService());
            var toUpdate = testPerson;

            UpdatePersonModel(toUpdate);
            var result = task.DoTask(toUpdate);

            Assert.IsTrue(result.Success);
            Assert.IsNull(result.Exception);
            Assert.IsNull(result.Data);

            var getPersonTask = new GetPerson(DbContext);
            var person        = getPersonTask.DoTask(toUpdate.Id)?.Data;

            Assert.IsNotNull(person);
            Assert.AreEqual(toUpdate.FirstName, person.FirstName);
            Assert.AreEqual(toUpdate.MiddleName, person.MiddleName);
            Assert.AreEqual(toUpdate.LastName, person.LastName);
            Assert.AreEqual(toUpdate.NameSuffix, person.NameSuffix);
            Assert.AreEqual(toUpdate.Email, person.Email);
            Assert.AreEqual(toUpdate.Phone, person.Phone);
            Assert.AreEqual(toUpdate.Address.Street, person.Address.Street);
            Assert.AreEqual(toUpdate.Address.City, person.Address.City);
            Assert.AreEqual(toUpdate.Address.Region, person.Address.Region);
            Assert.AreEqual(toUpdate.Address.PostalCode, person.Address.PostalCode);
            Assert.AreEqual(toUpdate.Address.Country.Name, person.Address.Country.Name);

            var removePersonTask   = new RemovePerson(DbContext);
            var removePersonResult = removePersonTask.DoTask(person);

            Assert.IsTrue(removePersonResult.Success);
            Assert.IsNull(removePersonResult.Exception);
        }
        private void ListOfExistingAgentsCombobox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Person selectedAgent = (sender as ComboBox).SelectedItem as Person;

            if (selectedAgent != null)
            {
                UpdatePerson = selectedAgent;

                if (selectedAgent.Agent != null)
                {
                    UpdateAgent           = selectedAgent.Agent;
                    AgentNameTextbox.Text = UpdatePerson.GetFirstAndLastName();

                    if (selectedAgent.Agent.CompanyID != null)
                    {
                        var agentsAffiliatedReco = (from re in ((App)Application.Current)._recosCollection
                                                    where selectedAgent.Agent.CompanyID == re.CompanyID
                                                    select re).FirstOrDefault();
                        UpdateAgentCompanyNameTextbox.Text = agentsAffiliatedReco.CompanyName;
                        UpdateReco = agentsAffiliatedReco;
                    }
                    else
                    {
                        UpdateAgentCompanyNameTextbox.Text = "Agent no longer active";
                    }

                    UpdateAgentCommissionTextbox.Text = UpdateAgent.CommissionPercent.ToString().Trim();
                }

                if (selectedAgent.Agent == null)
                {
                    AgentNameTextbox.IsReadOnly        = true;
                    AddNewAgentButton.IsEnabled        = true;
                    AddNewAgentButton.Visibility       = Visibility.Visible;
                    UpdateAgentCompanyNameTextbox.Text = "Click ADD NEW.";
                    UpdateAgentCommissionTextbox.Text  = "Click ADD NEW";
                }

                UpdateHomeSale.AgentID = UpdateAgent.AgentID;
            }
        }
Example #20
0
        public UpdatePerson GetUpdatePersonDto()
        {
            var person = new UpdatePerson()
            {
                Message = new Dto.Soap.Message()
                {
                    DataUpdate = new DataUpdate()
                    {
                        TraceNumber    = "123456",
                        ProcessingCode = "ExternalUpdateRequest",
                        Source         = "LoanOrigination",
                        UpdateAction   = "Modify",
                        Person         = new Person()
                        {
                            PartyNumber    = "99999999",
                            TaxIdNumber    = "999999999",
                            PrimaryAddress = new PrimaryAddress()
                            {
                                AddressLine1 = "123 Oak Court"
                            }
                        },
                        ModifiedFields = new List <ModifiedFields>()
                        {
                            new ModifiedFields()
                            {
                                AddressField = new List <string>()
                                {
                                    "AddressLine1"
                                }
                            }
                        }
                    }
                }
            };

            return(person);
        }
Example #21
0
 public IActionResult EditPerson(UpdatePerson updatePerson)
 {
     return(View("EditPerson", updatePerson));
 }
Example #22
0
        public void Handle(ImportUsfPerson command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }

            var reportBuilder = command.ReportBuilder ?? new WorkReportBuilder("Import USF Person");

            // find user by id
            reportBuilder.Report("Querying database for user #{0}.", command.UserId);
            var user = _entities.Get <User>()
                       .EagerLoad(_entities, new Expression <Func <User, object> >[]
            {
                x => x.Person.Affiliations,
            })
                       .Single(x => x.RevisionId == command.UserId);

            reportBuilder.Report("Found matching user with name '{0}'.", user.Name);

            // invoke USF person service
            reportBuilder.Report("Invoking USF person service with user name '{0}'.", user.Name);
            //const string testJson = "{\"Last Name\":\"Hernandez\",\"First Name\":\"Mario\",\"Middle Name\":\" \",\"Suffix\":\" \",\"Gender\":\"Male\",\"USF Email Address\":\"[email protected]\",\"lastUpdate\":\"05-28-2013\",\"profile\":[{\"DEPTID\":\"0-5830-001\",\"Faculty Rank\":\"2\",\"Position Title\":\"Professor\",\"Institutional Affiliation\":\"USF Tampa\",\"College\":\"College of Behavioral and Community Sciences\",\"Department/Program\":\"Division of Administration and Communication\"},{\"DEPTID\":\"0-6405-000\",\"Faculty Rank\":\"2\",\"Position Title\":\"Professor\",\"Institutional Affiliation\":\"USF Tampa\",\"College\":\"College of Public Health\",\"Department/Program\":\"Department of Community and Family Health\"}]}";
            //var usfPerson = JsonConvert.DeserializeObject<UsfPersonData>(testJson);
            var usfPerson = _queryProcessor.Execute(new UsfPerson(command.Service, user.Name)
            {
                ReportBuilder = reportBuilder,
            });

            if (usfPerson == null)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Could not obtain data for user '{2}' using '{0}_{1}'service integration.",
                                                        command.Service.Integration.Name, command.Service.Integration.TenantId, user.Name));
            }
            reportBuilder.Report("Deserialized USF person response to CLR object.");
            reportBuilder.Report("JSON value of deserialized response is:");
            reportBuilder.Report(JsonConvert.SerializeObject(usfPerson));

            reportBuilder.Report("Invoking command to import USF organization data.");
            _importEstablishments.Handle(new ImportUsfEstablishments(command.Principal, command.Service, usfPerson.LastUpdate)
            {
                ReportBuilder = reportBuilder,
            });

            // check affiliations (only do this once when created)
            if (usfPerson.Affiliations != null && usfPerson.Affiliations.Any())
            {
                reportBuilder.Report("USF person has affiliations, loading offspring and module settings.");
                var usf = _entities.Query <Establishment>()
                          .EagerLoad(_entities, new Expression <Func <Establishment, object> >[]
                {
                    x => x.Offspring,
                })
                          .Single(x => x.RevisionId == command.Service.Integration.TenantId);
                var offspring = usf.Offspring.Select(x => x.Offspring).ToArray();
                var settings  = _queryProcessor.Execute(new EmployeeSettingsByEstablishment(usf.RevisionId)
                {
                    EagerLoad = new Expression <Func <EmployeeModuleSettings, object> >[]
                    {
                        x => x.FacultyRanks,
                    },
                });
                reportBuilder.Report("Iterating over {0} affiliations.", usfPerson.Affiliations.Length);
                var createdAffiliations = new List <Affiliation>();
                foreach (var usfAffiliation in usfPerson.Affiliations)
                {
                    // make sure the establishment exists
                    var establishment = offspring.SingleOrDefault(x => x.CustomIds.Any(y => y.Value == usfAffiliation.DepartmentId));
                    if (establishment == null)
                    {
                        throw new InvalidOperationException(string.Format(
                                                                "Could not find UCosmic establishment for USF Department '{0}'.", usfAffiliation.DepartmentId));
                    }

                    // make sure the affiliation is not a duplicate
                    if (createdAffiliations.Any(x => x.EstablishmentId == establishment.RevisionId && x.PersonId == user.Person.RevisionId))
                    {
                        continue;
                    }

                    var facultyRank = settings.FacultyRanks.SingleOrDefault(x => x.Rank == usfAffiliation.PositionTitle);
                    var createAffiliationCommand = new CreateAffiliation(command.Principal, user.Person.RevisionId, establishment.RevisionId)
                    {
                        NoCommit      = true,
                        FacultyRankId = facultyRank != null ? facultyRank.Id : (int?)null,
                    };
                    _createAffiliation.Handle(createAffiliationCommand);
                    createdAffiliations.Add(createAffiliationCommand.Created);
                }
            }

            // possibly add a new email addresss
            if (!user.Name.Equals(usfPerson.EmailAddress, StringComparison.OrdinalIgnoreCase))
            {
                reportBuilder.Report("USF person has email address '{0}' different from username.", usfPerson.EmailAddress);

                // create user command will already have created an email based on the username / EPPN
                // we trust USF email addresses, so change the email added during person creation
                user.Person.Emails.Single(x => x.IsDefault).Value = usfPerson.EmailAddress;
            }

            // update person
            var displayName = _queryProcessor.Execute(new GenerateDisplayName
            {
                FirstName  = usfPerson.FirstName,
                MiddleName = usfPerson.MiddleName,
                LastName   = usfPerson.LastName,
                Suffix     = usfPerson.Suffix,
            });

            if (string.IsNullOrWhiteSpace(displayName))
            {
                displayName = usfPerson.EmailAddress;
            }
            var updatePersonCommand = new UpdatePerson(command.Principal, user.Person.RevisionId)
            {
                NoCommit             = true,
                FirstName            = usfPerson.FirstName,
                MiddleName           = usfPerson.MiddleName,
                LastName             = usfPerson.LastName,
                Gender               = string.IsNullOrWhiteSpace(usfPerson.Gender) ? "P" : usfPerson.Gender.Substring(0, 1).ToUpper(),
                Suffix               = usfPerson.Suffix,
                DisplayName          = displayName,
                IsDisplayNameDerived = false,
                IsActive             = true,
            };

            _updatePerson.Handle(updatePersonCommand);

            reportBuilder.Report("Committing changes based on USF person response.");
            _entities.SaveChanges();
            reportBuilder.Report("Committed changes based on USF person response.");
        }
 public IPersonModel Any(UpdatePerson request)
 {
     return(workflow.Update(request));
 }
 public async Task<ActionResult> Edit(UpdatePerson getPerson)
 {
     var person = await _mediator.SendAsync(getPerson);
     return RedirectToAction("Details", new { Id = person.Id });
 }
        public async Task <ActionResult <Person> > Update(UpdatePerson request)
        {
            var person = await mediator.Send(request);

            return(person);
        }
Example #26
0
 public void TearDown()
 {
     _person = null;
     _app    = null;
 }
Example #27
0
 public void UpdateDeelnemer(UpdatePerson deelnemer)
 {
     _sender.PublishCommand(deelnemer);
 }
Example #28
0
        public BaseResult TestConnection(string serviceUrl, string userName, string password, string facility)
        {
            var result = new BaseResult();

            using (var tr = new Tracer("LMS.Connector.CCM.Behaviors.Soap.TestConnectionBehavior.TestConnection"))
            {
                _soapRepository.Credentials = new Credentials()
                {
                    BaseUrl  = serviceUrl,
                    Username = userName,
                    Password = password,
                    Facility = facility
                };

                tr.LogObject(_soapRepository.Credentials);

                // Can be any primary Applicant -- doesn't matter since we are only testing a connection.
                var lmsPerson = new LmsPerson()
                {
                    Applicant = _app.Applicants.SingleOrDefault(a => a.ApplicantTypeId == (int)Akcelerant.Lending.Lookups.Constants.Values.ApplicantType.Primary)
                };

                tr.Log($"UpdatePerson _person null? => {_person == null}");
                if (_person == null)
                {
                    tr.Log("Call GetDto() to get new _person");
                    _person = GetDto(lmsPerson);
                }
                tr.LogObject(_person);

                try
                {
                    tr.Log("Calling ISoapRespository.UpdatePerson");
                    _messageResponse = _soapRepository.UpdatePerson(_person, _app);

                    tr.Log($"_messageResponse.ResponseCode = {_messageResponse?.ResponseCode}");
                    tr.Log($"_messageResponse.ErrorMessage = {_messageResponse?.ErrorMessage}");

                    var isSystemMalfunction = (_messageResponse?.ResponseCode.Equals("SystemMalfunction", StringComparison.InvariantCulture) == true) ? true : false;
                    tr.Log($"isSystemMalfunction = {isSystemMalfunction}");

                    var isErrorMessageModifyPartyRequestFailed = (_messageResponse?.ErrorMessage.Contains($"Modify Party request failed. Party {_person.Message?.DataUpdate?.Person?.PartyNumber} not found.") == true) ? true : false;
                    tr.Log($"isErrorMessageModifyPartyRequestFailed = {isErrorMessageModifyPartyRequestFailed}");

                    //Use reponseCode and errorMessage to derive connectionEstablished according to business rules
                    _connectionEstablished = (isSystemMalfunction && isErrorMessageModifyPartyRequestFailed) ? true : false;
                    tr.Log($"_connectionEstablished = {_connectionEstablished}");
                }
                catch (Exception ex)
                {
                    result.Result      = false;
                    result.ExceptionId = Utility.LogError(ex, "LMS.Connector.CCM.Behaviors.Soap.TestConnectionBehavior.TestConnection");
                    result.AddMessage(MessageType.Error, $"Exception when attempting to get a MessageResponse from SOAP Repository UpdateAccount(): {ex.Message}");
                }
                finally
                {
                    // Deallocate DTO
                    _person = null;
                }

                if (_connectionEstablished)
                {
                    result.Result = true;
                }
                else
                {
                    result.Result = false;
                    result.AddMessage(MessageType.Error, "Connection to CCM SOAP service was not established");
                }
            }

            return(result);
        }
Example #29
0
 public IActionResult Save(UpdatePerson p)
 {
     return(RedirectToAction("List", "Home"));
 }
Example #30
0
 public async Task <IActionResult> Put(UpdatePerson command)
 => await SendAsync(command.Bind(c => c.Id, UserId),
                    resourceId : command.Id, resource : "people");
Example #31
0
 public void SetUp()
 {
     _person    = GetUpdatePersonDto();
     _app       = GetApplication();
     _userToken = "aBc123";
 }