Ejemplo n.º 1
0
        public int ModificarPersona(CPerson per)
        {
            using (SchoolEntities contexto = new SchoolEntities())
            {
                try
                {
                    var query = contexto.Person.Select(p => new CPerson
                    {
                        PersonID  = p.PersonID,
                        LastName  = p.LastName,
                        FirstName = p.FirstName
                    }).Where(x => x.PersonID == per.PersonID).First();

                    query.FirstName      = per.FirstName;
                    query.LastName       = per.LastName;
                    query.HireDate       = per.HireDate;
                    query.EnrollmentDate = per.EnrollmentDate;

                    int resultado = contexto.SaveChanges();
                    return(resultado);
                }
                catch (Exception ex)

                {
                    return(-1);
                }
            }
        }
Ejemplo n.º 2
0
 public int InsertarPersona(CPerson per)
 {
     using (SchoolEntities contexto = new SchoolEntities())
     {
         try
         {
             Person person = new Person();
             person.PersonID       = per.PersonID;
             person.FirstName      = per.FirstName;
             person.LastName       = per.LastName;
             person.HireDate       = per.HireDate;
             person.EnrollmentDate = per.EnrollmentDate;
             contexto.Person.Add(person);
             int resultado = contexto.SaveChanges();
             return(resultado);
         }
         catch (Exception ex)
         {
             return(-1);
         }
     }
 }