Example #1
0
 public void Post([FromBody] Employee newEmployee)
 {
     using (myDBEntities = new MyDBEntities())
     {
         myDBEntities.Employees.Add(newEmployee);
     }
 }
Example #2
0
        public IEnumerable <Object> Get()
        {
            using (myDBEntities = new MyDBEntities()) {
                var query = from dbEmployees in myDBEntities.Employees
                            select new { dbEmployees.EmpName, dbEmployees.Email };

                var listOfEmployees = query.ToList();
                return(listOfEmployees);
            }
        }
Example #3
0
 public Object Get(int id)
 {
     using (myDBEntities = new MyDBEntities())
     {
         var employeeObj = myDBEntities
                           .Employees.Where(employee => employee.EmpID == id)
                           .FirstOrDefault();
         return(new
         {
             EmpName = employeeObj.EmpName,
             Email = employeeObj.Email,
             EmpId = employeeObj.EmpID
         });
     }
 }