Example #1
0
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Number,DepartmentID,DesignationID,EmployeeTypeID")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                BaseEmployeeFactory bEmpFact = new EmployeeManagerFactory().GetFactory(employee);
                bEmpFact.CalculateSalary();
                db.Employees.Add(employee);
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            ViewBag.DepartmentID   = new SelectList(db.Departments, "Id", "DepartmentName", employee.DepartmentID);
            ViewBag.DesignationID  = new SelectList(db.Designations, "Id", "DesignationName", employee.DesignationID);
            ViewBag.EmployeeTypeID = new SelectList(db.EmployeeTypes, "Id", "EmployeeTypeName", employee.EmployeeTypeID);
            return(View(employee));
        }