Example #1
0
        public static IEnumerable <EmployeeModel> GetNames()
        {
            using (var context = new Data.NorthwindEntities())
            {
                var employees = context.Employees.Select(e => new EmployeeModel
                {
                    Id   = e.EmployeeID,
                    Name = e.FirstName + " " + e.LastName
                }).ToList();

                return(employees);
            }
        }
Example #2
0
        public static Employee GetDetails(int id)
        {
            using (var context = new Data.NorthwindEntities())
            {
                var employee = context.Employees.Find(id);

                if (employee == null)
                {
                    throw new ArgumentOutOfRangeException("No such employee was found!");
                }

                return(employee);
            }
        }
Example #3
0
        public EmployeeModel GetDetails(int id)
        {
            using (var context = new Data.NorthwindEntities())
            {
                var employee = context.Employees.Find(id);

                if (employee == null)
                {
                    throw new HttpRequestException("No such user found");
                }

                return(new EmployeeModel
                {
                    Photo = employee.Photo,
                    Phone = employee.HomePhone,
                    Email = employee.FirstName + "." + employee.LastName + "@northwnd.com",
                    Address = employee.Address,
                    Notes = employee.Notes
                });
            }
        }