public IEnumerable<Person> GetPeople()
        {
            var people = new List<Person>();

            if (File.Exists(path))
            {
                using (var sr = new StreamReader(path))
                {
                    string line;
                    while ((line = sr.ReadLine()) != null)
                    {
                        var elems = line.Split(',');
                        var per = new Person()
                        {
                            FirstName = elems[0],
                            LastName = elems[1],
                            StartDate = DateTime.Parse(elems[2]),
                            Rating = Int32.Parse(elems[3])
                        };
                        people.Add(per);
                    }
                }
            }
            return people;
        }
        public void UpdatePerson(string lastName, Person updatedPerson)
        {
            using (var context = new PeopleEntities())
            {
                var foundPerson = GetDataPerson(context, lastName);
                if (foundPerson == null)
                    return;

                foundPerson.FirstName = updatedPerson.FirstName;
                foundPerson.LastName = updatedPerson.LastName;
                foundPerson.StartDate = updatedPerson.StartDate;
                foundPerson.Rating = updatedPerson.Rating;

                context.SaveChanges();
            }
        }
        public void AddPerson(Person newPerson)
        {
            using (var context = new PeopleEntities())
            {
                if (GetDataPerson(context, newPerson.LastName) != null)
                    return;

                var person = new DataPerson()
                {
                    FirstName = newPerson.FirstName,
                    LastName = newPerson.LastName,
                    StartDate = newPerson.StartDate,
                    Rating = newPerson.Rating,
                };
                context.DataPersons.Add(person);
                context.SaveChanges();
            }
        }
Exemplo n.º 4
0
        public Person GetPerson(string lastName)
        {
            Person selPerson = new Person();
            if (File.Exists(path))
            {
                var sr = new StreamReader(path);
                string line;
                while ((line = sr.ReadLine()) != null)
                {
                    var elems = line.Split(',');
                    if (elems[1].ToLower() == lastName.ToLower())
                    {
                        selPerson.FirstName = elems[0];
                        selPerson.LastName = elems[1];
                        selPerson.StartDate = DateTime.Parse(elems[2]);
                        selPerson.Rating = Int32.Parse(elems[3]);
                    }
                }
            }

            return selPerson;
        }
 public void UpdatePerson(string lastName, Person updatedPerson)
 {
     throw new NotImplementedException();
 }
 public void AddPerson(Person newPerson)
 {
     throw new NotImplementedException();
 }
 public void UpdatePerson(string lastName, Person updatedPerson)
 {
     proxy.UpdatePerson(lastName, updatedPerson);
 }
 public void AddPerson(Person newPerson)
 {
     proxy.AddPerson(newPerson);
 }
Exemplo n.º 9
0
 public System.Threading.Tasks.Task UpdatePersonAsync(string lastName, PersonRepository.Interface.Person updatedPerson)
 {
     return(base.Channel.UpdatePersonAsync(lastName, updatedPerson));
 }
Exemplo n.º 10
0
 public void UpdatePerson(string lastName, PersonRepository.Interface.Person updatedPerson)
 {
     base.Channel.UpdatePerson(lastName, updatedPerson);
 }
Exemplo n.º 11
0
 public System.Threading.Tasks.Task AddPersonAsync(PersonRepository.Interface.Person newPerson)
 {
     return(base.Channel.AddPersonAsync(newPerson));
 }
Exemplo n.º 12
0
 public void AddPerson(PersonRepository.Interface.Person newPerson)
 {
     base.Channel.AddPerson(newPerson);
 }
Exemplo n.º 13
0
 public void AddPerson(Person newPerson)
 {
     serviceProxy.AddPerson(newPerson);
 }
 private Person GetPersonFromDataPerson(DataPerson dataPerson)
 {
     var person = new Person()
     {
         FirstName = dataPerson.FirstName,
         LastName = dataPerson.LastName,
         StartDate = dataPerson.StartDate.Value,
         Rating = dataPerson.Rating.Value,
     };
     return person;
 }