Esempio n. 1
0
        public List <Person> GetPersons(int currentPageNumber, int pageSize, string sortExpression, string sortDirection, out TransactionalInformation transaction)
        {
            transaction = new TransactionalInformation();

            var persons = new List <Person>();

            try
            {
                int totalRows;

                _personDataService.CreateSession();
                persons = _personDataService.GetPersons(currentPageNumber, pageSize, sortExpression, sortDirection, out totalRows);
                _personDataService.CloseSession();

                transaction.TotalPages = Utility.CalculateTotalPages(totalRows, pageSize);
                transaction.TotalRows  = totalRows;

                transaction.ReturnStatus = true;
            }
            catch (Exception ex)
            {
                string errorMessage = ex.Message;
                transaction.ReturnMessage.Add(errorMessage);
                transaction.ReturnStatus = false;
            }
            finally
            {
                _personDataService.CloseSession();
            }

            return(persons);
        }
        public IActionResult GetPersons()
        {
            var person = _dataService.GetPersons().GetRange(0, 500);

            IList <PersonDTO> newPersonDTO = person.Select(x => new PersonDTO
            {
                Id        = x.Id,
                Name      = x.Name,
                BirthYear = x.BirthYear,
                DeathYear = x.DeathYear,
                Url       = "http://localhost:5001/api/name/" + x.Id
            }).ToList();

            return(Ok(newPersonDTO));
        }