Exemple #1
0
        // GET: Employee
        public ActionResult Index()
        {
            EmployeeBussinessLayer employeeBussinessLayer = new EmployeeBussinessLayer();
            List <Employee>        employees = employeeBussinessLayer.Employees.ToList();

            return(View(employees));
        }
        public ActionResult Index(string ID)
        {
            EmployeeListViewModel    emplv     = new EmployeeListViewModel();
            EmployeeBussinessLayer   empbl     = new EmployeeBussinessLayer();
            List <Employee>          employees = empbl.GetEmployees();
            List <EmployeeViewModel> empview   = new List <EmployeeViewModel>();

            foreach (Employee emp in employees)
            {
                EmployeeViewModel empViewModel = new EmployeeViewModel();
                empViewModel.EmployeeName = emp.FName + " " + emp.LName;
                empViewModel.Salary       = emp.Salary.ToString();
                if (emp.Salary > 15000)
                {
                    empViewModel.SalaryColor = "yellow";
                }
                else
                {
                    empViewModel.SalaryColor = "green";
                }
                empview.Add(empViewModel);
            }
            emplv.Employee = empview;
            return(View("Index", emplv));
        }
        public ActionResult Index()
        {
            EmployeeListViewModel    emplv     = new EmployeeListViewModel();
            EmployeeBussinessLayer   empbl     = new EmployeeBussinessLayer();
            List <Employee>          employees = empbl.GetEmployees();
            List <EmployeeViewModel> empview   = new List <EmployeeViewModel>();

            emplv.UserName = User.Identity.Name;
            //emplv.FooterData.CompanyName = "ADDFG FJHDHDHDH JDJFHDHFHF";
            // emplv.FooterData.Year = "2018 - @Copyright";
            foreach (Employee emp in employees)
            {
                EmployeeViewModel empViewModel = new EmployeeViewModel();
                empViewModel.EmployeeName = emp.FName + " " + emp.LName;
                empViewModel.Salary       = emp.Salary.ToString();
                if (emp.Salary > 15000)
                {
                    empViewModel.SalaryColor = "yellow";
                }
                else
                {
                    empViewModel.SalaryColor = "green";
                }
                empview.Add(empViewModel);
            }
            emplv.Employee = empview;
            return(View("Index", emplv));
        }
        public ActionResult SaveEmployee(Employee e, string BtnSave)
        {
            switch (BtnSave)
            {
            case "Save Employee":
                if (ModelState.IsValid)
                {
                    EmployeeBussinessLayer empbl = new EmployeeBussinessLayer();
                    empbl.SaveEmployee(e);
                    return(RedirectToAction("Index"));
                }
                else
                {
                    // return View("CreateEmployee");

                    // to maintain data on validation
                    CreateEmployeeViewModel cevm = new CreateEmployeeViewModel();
                    cevm.FiName = e.FName;
                    cevm.LaName = e.LName;
                    if (e.Salary.HasValue)
                    {
                        cevm.Salary1 = e.Salary.ToString();
                    }
                    else
                    {
                        cevm.Salary1 = ModelState["Salary"].Value.AttemptedValue;
                    }
                    return(View("CreateEmployee", cevm));
                }

            case "Cancel":
                return(RedirectToAction("Index"));
            }
            return(new EmptyResult());
        }
Exemple #5
0
 public ActionResult DoLogin(UserDetails u)
 {
     if (ModelState.IsValid)
     {
         EmployeeBussinessLayer ebl = new EmployeeBussinessLayer();
         UserStatus             us  = ebl.GetUserValidity(u);
         bool IsAdmin = false;
         if (us == UserStatus.AuthenticatedAdmin)
         {
             IsAdmin = true;
         }
         else if (us == UserStatus.AuthenticatedUser)
         {
             IsAdmin = false;
         }
         else
         {
             ModelState.AddModelError("ABCD", "Invalid Username / Password");
             return(View("Login"));
         }
         FormsAuthentication.SetAuthCookie(u.UserName, false);
         Session["IsAdmin"] = IsAdmin;
         return(RedirectToAction("Index", "Employee"));
     }
     else
     {
         return(View("Login"));
     }
 }
Exemple #6
0
        public ActionResult create(FormCollection formCollection)
        {
            Employee employee = new Employee();

            employee.Name        = formCollection["Name"];
            employee.Gender      = formCollection["Gender"];
            employee.City        = formCollection["City"];
            employee.DateOfBirth = Convert.ToDateTime(formCollection["DateOfBirth"]);

            EmployeeBussinessLayer employeeBussinessLayer = new EmployeeBussinessLayer();

            employeeBussinessLayer.AddEmployee(employee);
            return(RedirectToAction("Index"));
        }
Exemple #7
0
        public async Task <ActionResult> BulkUpload(FileUploadViewModel model)
        {
            // **** for synchronus calll
            //List<Employee> employees = GetEmployees(model);
            //EmployeeBussinessLayer bal = new EmployeeBussinessLayer();
            //bal.UploadEmployees(employees);
            //return RedirectToAction("Index", "Employee");

            //**** for asynchronus call
            int             t1        = Thread.CurrentThread.ManagedThreadId;
            List <Employee> employees = await Task.Factory.StartNew <List <Employee> >(() => GetEmployees(model));

            int t2 = Thread.CurrentThread.ManagedThreadId;
            EmployeeBussinessLayer bal = new EmployeeBussinessLayer();

            bal.UploadEmployees(employees);
            return(RedirectToAction("Index", "Employee"));
        }