public IEnumerable <IEmployeeSalesReportData> Executequery()
        {
            var reportData = new List <IEmployeeSalesReportData>();

            using (PortfolioProjectContext portfolioContext = new PortfolioProjectContext())
            {
                var queryResult = (from emp in portfolioContext.Employees
                                   join ord in portfolioContext.Orders on emp.UserId equals ord.UserId
                                   join prod in portfolioContext.Products on ord.ProductId equals prod.ProductId
                                   join prodCat in portfolioContext.ProductCategories on prod.ProductCategoryId equals prodCat.ProductCategoryId
                                   //where _reportParams.employeeId.Contains(emp.UserId)
                                   select new EmployeeSalesReportData
                {
                    employeeFullName = emp.FirstName + " " + emp.LastName,
                    saleDate = ord.SaleDate,
                    salePrice = prod.Price,
                    productDescription = prod.Description,
                    productCategory = prodCat.CategoryName,
                    userID = emp.UserId
                });

                //reportData = _applyFilters.filter(_reportParams, queryResult).ToList();
                reportData = queryResult.ToList <IEmployeeSalesReportData>();
            }

            return(reportData);
        }
Esempio n. 2
0
 public void CreateEmployee(Employee employee)
 {
     using (var dbContext = new PortfolioProjectContext())
     {
         dbContext.Employees.Add(employee);
         dbContext.SaveChanges();
     }
 }
Esempio n. 3
0
 public void UpdateEmployee(Employee employee)
 {
     using (var dbContext = new PortfolioProjectContext())
     {
         dbContext.Entry(employee).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Esempio n. 4
0
        public IEnumerable <Employee> GetCampaignNameFromProgram()
        {
            var employees = new List <Employee>();

            using (var dbContext = new PortfolioProjectContext())
            {
                employees = dbContext.Employees.ToList();
            }

            return(employees);
        }
Esempio n. 5
0
        public Employee GetEmployees(int id)
        {
            var employees = new Employee();

            using (var dbContext = new PortfolioProjectContext())
            {
                employees = dbContext.Employees
                            .Where(x => x.UserId == id)
                            .SingleOrDefault();
            }
            return(employees);
        }
Esempio n. 6
0
        public IEnumerable <City> GetCities()
        {
            var cities = new List <City>();

            using (var portfolioContext = new PortfolioProjectContext())
            {
                cities = portfolioContext
                         .Cities
                         .OrderBy(s => s.City1)
                         .ToList();
            }
            return(cities);
        }
Esempio n. 7
0
        public void DeleteEmployee(int employeeId)
        {
            using (var dbContext = new PortfolioProjectContext())
            {
                var emp = dbContext.Employees
                          .FirstOrDefault(x => x.UserId == employeeId);

                if (emp != null)
                {
                    dbContext.Employees.Remove(emp);
                    dbContext.SaveChanges();
                }
            }
        }
Esempio n. 8
0
        public IEnumerable <ITotalSalesByEmployee> GetData()
        {
            using (var portfolioContext = new PortfolioProjectContext())
            {
                var queryResult = (from emp in portfolioContext.Employees
                                   join ord in portfolioContext.Orders on emp.UserId equals ord.UserId
                                   join prod in portfolioContext.Products on ord.ProductId equals prod.ProductId
                                   select new EmployeeSales
                {
                    employeeName = emp.FirstName + " " + emp.LastName,
                    orderAmount = prod.Price
                });

                return(queryResult
                       .GroupBy(g => g.employeeName)
                       .Select(s => new TotalSalesByEmployeeModel
                {
                    employeeName = s.Key,
                    salesCount = s.Count(),
                    salesSum = s.Sum(s1 => s1.orderAmount),
                }).ToList <ITotalSalesByEmployee>());
            }
        }
Esempio n. 9
0
        public HttpStatusCode UpdateEmployee(Employee employee)
        {
            using (var dbContext = new PortfolioProjectContext())
            {
                if (employee != null)
                {
                    try
                    {
                        dbContext.Entry(employee).State = EntityState.Modified;
                        dbContext.SaveChanges();
                    }
                    catch
                    {
                        return(HttpStatusCode.InternalServerError);
                    }
                }
                else
                {
                    return(HttpStatusCode.NotFound);
                }
            }

            return(HttpStatusCode.OK);
        }