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); }
public void CreateEmployee(Employee employee) { using (var dbContext = new PortfolioProjectContext()) { dbContext.Employees.Add(employee); dbContext.SaveChanges(); } }
public void UpdateEmployee(Employee employee) { using (var dbContext = new PortfolioProjectContext()) { dbContext.Entry(employee).State = EntityState.Modified; dbContext.SaveChanges(); } }
public IEnumerable <Employee> GetCampaignNameFromProgram() { var employees = new List <Employee>(); using (var dbContext = new PortfolioProjectContext()) { employees = dbContext.Employees.ToList(); } return(employees); }
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); }
public IEnumerable <City> GetCities() { var cities = new List <City>(); using (var portfolioContext = new PortfolioProjectContext()) { cities = portfolioContext .Cities .OrderBy(s => s.City1) .ToList(); } return(cities); }
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(); } } }
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>()); } }
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); }