public ActionResult Create([Bind(Include = "Id,Name,JobDescription,Number,Department,HourlyPay,Bonus,EmployeeTypeID")] Employee.Web.Models.Employee employee)
        {
            if (ModelState.IsValid)
            {
                //calcaulate bonus
                // businees logic inside controller -- bad practice
                //if (employee.EmployeeTypeID ==1) // permanent
                //{
                //    employee.HourlyPay = 8;
                //    employee.Bonus = 10;
                //}
                //else if (employee.EmployeeTypeID == 2)
                //{
                //    employee.HourlyPay = 12;
                //    employee.Bonus = 5;
                //}
                BaseEmployeeFactory empFactory = new EmployeeManagerFactory().CreateFactory(employee);
                //IEmployeeManager empManager = empFactory.GetEmployeeManager(employee.EmployeeTypeID);
                //employee.Bonus = empManager.GetBonus();
                //employee.HourlyPay = empManager.GetHourlyPay();

                empFactory.ApplySalary();
                db.Employees.Add(employee);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.EmployeeTypeID = new SelectList(db.EmployeeTypes, "Id", "EmployeeType1", employee.EmployeeTypeID);
            return(View(employee));
        }
 public ActionResult DeleteConfirmed(int id)
 {
     Employee.Web.Models.Employee employee = db.Employees.Find(id);
     db.Employees.Remove(employee);
     db.SaveChanges();
     return(RedirectToAction("Index"));
 }
 public ActionResult Edit([Bind(Include = "Id,Name,JobDescription,Number,Department,HourlyPay,Bonus,EmployeeTypeID")] Employee.Web.Models.Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.EmployeeTypeID = new SelectList(db.EmployeeTypes, "Id", "EmployeeType1", employee.EmployeeTypeID);
     return(View(employee));
 }
 // GET: Employees/Details/5
 public ActionResult Details(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Employee.Web.Models.Employee employee = db.Employees.Find(id);
     if (employee == null)
     {
         return(HttpNotFound());
     }
     return(View(employee));
 }
 // GET: Employees/Edit/5
 public ActionResult Edit(int?id)
 {
     if (id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     Employee.Web.Models.Employee employee = db.Employees.Find(id);
     if (employee == null)
     {
         return(HttpNotFound());
     }
     ViewBag.EmployeeTypeID = new SelectList(db.EmployeeTypes, "Id", "EmployeeType1", employee.EmployeeTypeID);
     return(View(employee));
 }