Exemplo n.º 1
0
        // GET: Home
        public ActionResult Index()
        {
            List <Employee> emp = new List <Models.Employee>
            {
                new Employee {
                    empid = 1, empname = "yogesh", empsalary = 2000
                },
                new Employee {
                    empid = 2, empname = "Ranjit", empsalary = 7000
                },
                new Employee {
                    empid = 3, empname = "Bhupendra", empsalary = 1000
                }
            };
            //return View("Index", emp);

            List <EmployeeVM> empvmobj = new List <Models.EmployeeVM>();

            foreach (Employee empobj in emp)
            {
                EmployeeVM vmobj = new Models.EmployeeVM();
                vmobj.empname   = empobj.empname;
                vmobj.empsalary = empobj.empsalary;
                if (empobj.empsalary > 2000)
                {
                    vmobj.salarycolor = "red";
                }
                else
                {
                    vmobj.salarycolor = "green";
                }
                empvmobj.Add(vmobj);
            }
            return(View("VmView", empvmobj));
        }
Exemplo n.º 2
0
        public HttpResponseMessage GetEmployeeById(int id)
        {
            Models.EmployeeVM employee = new Models.EmployeeVM()
            {
                EmpID     = id,
                FirstName = "David",
                LastName  = "Hasting",
                Gender    = "Male",
                Salary    = 50000
            };

            return(Request.CreateResponse(HttpStatusCode.OK, employee));
        }