Exemplo n.º 1
0
        public Person ValidationDeletePerson(IDataServicesPerson serviceData)
        {
            Utils.ValidationNumber(this.Person.PersonId);
            var filter = new FilterPerson()
            {
                Id = this.Person.PersonId
            };
            var person = serviceData.GetPersons(filter).First();

            return(person);
        }
Exemplo n.º 2
0
        public ViewPerson GetPersonById(int idPerson)
        {
            var filter = new FilterPerson()
            {
                Id = idPerson
            };

            return(this.ServiceData.GetPersons(filter).Select(person => new ViewPerson()
            {
                PersonId = person.Id, PersonAge = person.Age, PersonName = person.Name, PersonType = person.PersonTypeId.ToString()
            }).First());
            //throw new NotImplementedException();
        }
Exemplo n.º 3
0
        public Person ValidationUpdatePerson(IDataServicesPerson serviceData)
        {
            Utils.ValidationNumber(this.Person.PersonId);
            Utils.ValidationText(this.Person.PersonName);
            Utils.ValidationNumber(this.Person.PersonAge);
            Utils.ValidationText(this.Person.PersonType);
            var filter = new FilterPerson()
            {
                Id = this.Person.PersonId
            };
            var person = serviceData.GetPersons(filter).First();

            person.Name         = this.Person.PersonName;
            person.Age          = this.Person.PersonAge;
            person.PersonTypeId = int.Parse(this.Person.PersonType);
            return(person);
        }
Exemplo n.º 4
0
 public List <ViewPerson> GetPersons()
 {
     try
     {
         var filter  = new FilterPerson();
         var persons = this.ServiceData.GetPersons(filter);
         return(persons.Select(person => new ViewPerson()
         {
             PersonId = person.Id,
             PersonName = person.Name,
             PersonAge = person.Age,
             PersonType = person.PersonTypeId.ToString()
         }).ToList());
     }
     catch (Exception ex)
     {
         return(new List <ViewPerson>());
     }
 }
        public Student[] getFilterStudent(FilterPerson fp)
        {
            Student[] result1 = new Student[alunos.Length];
            int       inx     = 0;

            foreach (Student s in alunos)
            {
                if (fp(s))
                {
                    result1[inx] = s;
                    inx++;
                }
            }

            Student[] result = new Student[inx];

            Array.Copy(result1, result, inx);

            return(result);
        }
        public Student[] getFilterStudent(FilterPerson fp)
        {
            Student[] result1 = new Student[alunos.Length];
            int inx = 0;

            foreach (Student s in alunos)
            {

                if (fp(s))
                {
                    result1[inx] = s;
                    inx++;
                }
            }

            Student[] result = new Student[inx];

            Array.Copy(result1, result, inx);
            
            return result;
        }
Exemplo n.º 7
0
        public List <Person> GetPersons(FilterPerson filters)
        {
            IQueryable <Person> persons = this.Context.Persons;

            if (filters.Id > 0)
            {
                return(persons.Where(person => person.Id == filters.Id).ToList());
            }
            if (!string.IsNullOrEmpty(filters.Name))
            {
                return(persons.Where(person => person.Name.Equals(filters.Name)).ToList());
            }
            if (filters.Age > 0)
            {
                return(persons.Where(person => person.Age == filters.Age).ToList());
            }
            if (filters.PersonType > 0)
            {
                return(persons.Where(person => person.PersonTypeId == filters.PersonType).ToList());
            }
            return(persons.ToList());
        }