Exemple #1
0
        public IActionResult Index()
        {
            List <Models.Employee> empList = new List <Models.Employee>();

            empList = _employeeDAL.GetEmployees().ToList();

            var _avgsal = _employeeDAL.AvgSal();

            ViewData["avgsal"] = _avgsal;
            var _avgage = _employeeDAL.AvgAge();

            ViewData["avgage"] = _avgage;


            int    sal  = Convert.ToInt32(TempData["sal"]);
            int    age  = Convert.ToInt32(TempData["age"]);
            string name = TempData["name"] as string;

            if (!string.IsNullOrEmpty(name))
            {
                if (sal > Convert.ToInt32(_avgsal))
                {
                    ViewData["salMessage"] = name + " is in above average salary";
                }
                else
                {
                    ViewData["salMessage"] = name + " is in below average salary";
                }
                if (age > Convert.ToInt32(_avgage))
                {
                    ViewData["ageMessage"] = name + " is in above average age";
                }
                else
                {
                    ViewData["ageMessage"] = name + " is in below average age";
                }
            }
            return(View(empList));
        }