Example #1
0
        //
        // GET: /Home/
        public ActionResult Index()
        {
            EmployeeContext employeeContext = new EmployeeContext();
            ViewBag.Departments = new SelectList(employeeContext.Departments, "Department_Id", "name");

            return View();
        }
        public void Guardar(Employee employee)
        {
            EmployeeContext employeeContext = new EmployeeContext();

            employeeContext.Employees.Add(employee);
            employeeContext.SaveChanges();
        }
 public void Delete(int id)
 {
     EmployeeContext employeeContext = new EmployeeContext();
     Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id);
     employeeContext.Employees.Remove(employee);
     employeeContext.SaveChanges();
 }
Example #4
0
        //
        // GET: /Department/
        public ActionResult Index()
        {
            EmployeeContext employeeContext = new EmployeeContext();

            List<Department> departments = employeeContext.Departments.ToList();

            return View(departments);
        }
Example #5
0
        //
        // GET: /Employee/
        public ActionResult Details(int id)
        {
            EmployeeContext employeeContext = new EmployeeContext();

            Employee employee = employeeContext.Employees.Single(emp => emp.EmployeeId == id);

            return View(employee);
        }
        public void SaveEmployee(Employee employee)
        {
            EmployeeContext employeeContext = new EmployeeContext();

            Employee empleado = employeeContext.Employees.First(emp => emp.EmployeeId == employee.EmployeeId);
            empleado.city = employee.city;
            empleado.Department = employee.Department;
            empleado.gender = employee.gender;
            empleado.name= employee.name;

            employeeContext.SaveChanges();
        }
Example #7
0
        public ActionResult EmployeesByDepartment()
        {
            EmployeeContext employeeContext = new EmployeeContext();

            var employees = employeeContext.Employees.Include("Department")
                            .GroupBy(x => x.Department.name)
                            .Select(y => new DepartmentTotals
                            {
                                name = y.Key,
                                total = y.Count()
                            }).ToList();

            return View(employees);
        }
Example #8
0
        public ActionResult Index()
        {
            EmployeeContext employeeContext = new EmployeeContext();
            List<Employee> employees = employeeContext.Employees.ToList();

            return View(employees);
        }
        public IEnumerable<Employee> Employees()
        {
            EmployeeContext employeeContext = new EmployeeContext();

            return employeeContext.Employees.ToList();
        }