コード例 #1
0
 public IEnumerable <Employee> GetEmployee()
 {
     using (SLKHUB_DBContext dbContext = new SLKHUB_DBContext())
     {
         return(dbContext.Employees.ToList());
     }
 }
コード例 #2
0
 public IEnumerable <Customer> GetCustomers()
 {
     using (SLKHUB_DBContext dbContext = new SLKHUB_DBContext())
     {
         return(dbContext.Customers.ToList());
     }
 }
コード例 #3
0
 public Employee Get(int id)
 {
     using (SLKHUB_DBContext dbContext = new SLKHUB_DBContext())
     {
         return(dbContext.Employees.FirstOrDefault(e => e.ID == id));
     }
 }
コード例 #4
0
        public IHttpActionResult GetCustomersById(int id)
        {
            using (SLKHUB_DBContext dbContext = new SLKHUB_DBContext())
            {
                //return dbContext.Customers.FirstOrDefault(e => e.Cust_Id == id);
                Customer customer = dbContext.Customers.Find(id);
                if (customer == null)
                {
                    return(NotFound());
                }

                return(Ok(customer));
            }
        }
コード例 #5
0
        public IHttpActionResult GetEmployeeById(int id)
        {
            using (SLKHUB_DBContext dbContext = new SLKHUB_DBContext())
            {
                // return dbContext.Employees.Find(id);

                Employee employee = dbContext.Employees.Find(id);
                if (employee == null)
                {
                    return(NotFound());
                }

                return(Ok(employee));
            }
        }