Esempio n. 1
0
 public IEmployeeInterface[] GetEmployeeList()
 {
     using (var context = new NextPetDbContext())
     {
         return((from b in context.Employee select b).ToArray());
     }
 }
Esempio n. 2
0
 public IEmployeeInterface GetOneEmployee(int id)
 {
     using (var context = new NextPetDbContext())
     {
         return(context.Employee.Find(id));
     }
 }
Esempio n. 3
0
 public IPetInterface[] GetEmployeePetList(int id)
 {
     using (var context = new NextPetDbContext())
     {
         return((from b in context.Pet select b).Where(pet => pet.EmployeeId == id).ToArray());
     }
 }
Esempio n. 4
0
 public IPetInterface GetOnePet(int id)
 {
     using (var context = new NextPetDbContext())
     {
         return(context.Pet.Find(id));
     }
 }
Esempio n. 5
0
 public IPetInterface[] GetPetList()
 {
     using (var context = new NextPetDbContext())
     {
         return((from b in context.Pet select b).ToArray());
     }
 }
Esempio n. 6
0
        public IEmployeeInterface PostEmployee(EmployeeModel employee)
        {
            // Insert employee
            using (var context = new NextPetDbContext()){
                context.Employee.Add(employee);
                context.SaveChanges();
            }

            return(employee);
        }
Esempio n. 7
0
        public bool DeleteEmployee(int id)
        {
            using (var context = new NextPetDbContext())
            {
                var employee = context.Employee.Find(id);
                context.Employee.Remove(employee);
                context.SaveChanges();

                return(true);
            }
        }
Esempio n. 8
0
        public bool DeletePet(int id)
        {
            using (var context = new NextPetDbContext())
            {
                var pet = context.Pet.Find(id);
                context.Pet.Remove(pet);
                context.SaveChanges();

                return(true);
            }
        }
Esempio n. 9
0
        public IPetInterface PostPet(PetModel pet)
        {
            // Insert pet
            using (var context = new NextPetDbContext())
            {
                context.Pet.Add(pet);
                context.SaveChanges();
            }

            return(pet);
        }
Esempio n. 10
0
        public IPetInterface PutPet(int id, PetModel petUpdated)
        {
            // Update pet
            using (var context = new NextPetDbContext())
            {
                var pet = context.Pet.Find(id);
                pet.Name       = petUpdated.Name;
                pet.Type       = petUpdated.Type;
                pet.BirthDate  = petUpdated.BirthDate;
                pet.EmployeeId = petUpdated.EmployeeId;

                context.Entry(pet).State = EntityState.Modified;
                context.SaveChanges();

                return(pet);
            }
        }
Esempio n. 11
0
        public IEmployeeInterface PutEmployee(int id, EmployeeModel employeeUpdated)
        {
            // Update employee
            using (var context = new NextPetDbContext())
            {
                var employee = context.Employee.Find(id);
                employee.FirstName = employeeUpdated.FirstName;
                employee.LastName  = employeeUpdated.LastName;
                employee.BirthDate = employeeUpdated.BirthDate;
                employee.City      = employeeUpdated.City;
                employee.Country   = employeeUpdated.Country;

                context.Entry(employee).State = EntityState.Modified;
                context.SaveChanges();

                return(employee);
            }
        }