Ejemplo n.º 1
0
        public void UpdatePerson(Person person, out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();

            try
            {
                var personBusinessRules = new PersonBusinessRules();
                var results             = personBusinessRules.Validate(person);

                bool validationSucceeded = results.IsValid;
                var  failures            = results.Errors;

                if (validationSucceeded == false)
                {
                    transaction = ValidationErrors.PopulateValidationErrors(failures);
                    return;
                }

                _personDataService.CreateSession();
                _personDataService.BeginTransaction();

                var existingPerson = _personDataService.GetPerson(person.PersonID);

                existingPerson.CompanyName  = person.CompanyName;
                existingPerson.Name         = person.Name;
                existingPerson.Country      = person.Country;
                existingPerson.City         = person.City;
                existingPerson.Address      = person.Address;
                existingPerson.MobileNumber = person.MobileNumber;
                existingPerson.Image        = person.Image;

                _personDataService.UpdatePerson(person);
                _personDataService.CommitTransaction(true);

                transaction.ReturnStatus = true;
                transaction.ReturnMessage.Add("Person was successfully updated.");
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                transaction.ReturnMessage.Add(errorMessage);
                transaction.ReturnStatus = false;
            }
            finally
            {
                _personDataService.CloseSession();
            }
        }
Ejemplo n.º 2
0
        public IActionResult GetPerson(string id)
        {
            var person           = _dataService.GetPerson(id);
            var profession       = _dataService.GetProfessionByPersonId2(id);
            var personKnownTitle = _dataService.GetPersonKnownTitles(id);

            IList <ProfessionDTO> professionDtos = profession.Select(x => new ProfessionDTO
            {
                ProfessionName = x.Profession.ProfessionName,
                Id             = x.Profession.Id,
                Url            = "http://localhost:5001/api/" + x.Profession.ProfessionName
            }).ToList();

            IList <PersonDTO> personDtos = person.Select(x => new PersonDTO
            {
                Id        = x.Id,
                Name      = x.Name,
                BirthYear = x.BirthYear,
                DeathYear = x.DeathYear
            }).ToList();

            IList <PersonKnownTitleDTO> personKnownTitleDtos = personKnownTitle.Select(x => new PersonKnownTitleDTO
            {
                Id        = x.Id,
                TitleId   = x.TitleId,
                TitleName = _titleDataService.GetTitle(x.TitleId).OriginalTitle.ToString(),
                Url       = "http://localhost:5001/api/title/" + x.TitleId
            }).ToList();

            return(Ok(new { personDtos, professionDtos, personKnownTitleDtos }));
        }
Ejemplo n.º 3
0
        private async Task LoginAsync()
        {
            var person = new PersonModel()
            {
                Email    = this.Email,
                Password = this.Password
            };

            person = _personData.GetPerson(person);
            if (person != null)
            {
                _cache.SaveUser(person);
                await _navigation.Close(this, person);
            }
        }