Beispiel #1
0
 public ActionResult SaveEmployee(Employee emp)
 {
     EmployeeBusinessLayer empbal = new EmployeeBusinessLayer();
     empbal.SaveEmployee(emp);
     EmployeeViewModel empViewModel = new EmployeeViewModel();
     empViewModel.EmployeeName = emp.FirstName + " " + emp.LastName;
     empViewModel.Salary = emp.Salary.ToString("c");
     if(emp.Salary>15000)
     {
         empViewModel.SalaryColor = "yellow";
     }
     else
     {
         empViewModel.SalaryColor = "green";
     }
     return Json(empViewModel);
 }
Beispiel #2
0
        public ActionResult SaveEmployee(Employee e)
        {
            if (ModelState.IsValid)
            {
                EmployeeBusinessLayer empBal = new EmployeeBusinessLayer();
                empBal.SaveEmployee(e);

                return RedirectToAction("Index");
            }
            else
            {
                CreateEmployeeViewModel vm = new CreateEmployeeViewModel();
                vm.FirstName = e.FirstName;
                vm.LastName = e.LastName;

                vm.Salary = e.Salary.ToString();

                //vm.FooterData = new FooterViewModel()
                //{
                //    CompanyName = "CompanyName",
                //     Year = DateTime.Now.Year.ToString()
                //};

                //vm.UserName = User.Identity.Name;

                return View("CreateEmployee",vm);
            }
            //return new EmptyResult();
        }