public List<Position> Position_List() { using (var context = new ToolsContext()) { return context.Positions.ToList(); } }
public List<CategoryDTO> CategoryStockList() { using (ToolsContext context = new ToolsContext()) { #region Student Code here //insert query code var data = from cat in context.Categories orderby cat.CategoryID select new CategoryDTO() { CategoryDescription = cat.Description, Stocks = from item in cat.StockItems select new CategoryStockItem() { Name = item.Description, OnHand = item.QuantityOnHand, Markup = item.SellingPrice - item.PurchasePrice } }; //replace the following line of code to return your results return data.ToList(); #endregion } }
public List<Category> Categories_List() { using (ToolsContext context = new ToolsContext()) { return context.Categories.ToList(); } }
public Category Categories_FindbyID(int categoryid) { using (ToolsContext context = new ToolsContext()) { return context.Categories.Find(categoryid); } }
public List<Employee> EmployeePosition(int positionId) { using(var context = new ToolsContext()) { var data = from info in context.Employees where info.PositionID == positionId select info; return data.ToList(); } }
public void Categories_Delete(Category removeItem) { using (ToolsContext context = new ToolsContext()) { #region Student Code here //insert Delete code var existingvalue = context.Categories.Find(removeItem.CategoryID); context.Categories.Remove(existingvalue); context.SaveChanges(); #endregion } }
public void Categories_Add(Category item) { using (ToolsContext context = new ToolsContext()) { #region Student Code here //insert add code var adding = context.Categories.Add(item); context.SaveChanges(); //replace the following line of code to return your results // return 0; #endregion } }
public void Categories_Update(Category item) { using (ToolsContext context = new ToolsContext()) { #region Student Code here //insert udpate code var updating = context.Categories.Attach(item); var matchingWithExistingValues = context.Entry<Category>(updating); matchingWithExistingValues.State = System.Data.Entity.EntityState.Modified; context.SaveChanges(); #endregion } }
public List<EmployeesPOCOs> getEmployeesPOCOs(int positionId) { using(var context = new ToolsContext()) { var result = from Employee in context.Employees where Employee.Position.PositionID == positionId orderby Employee.EmployeeID descending select new EmployeesPOCOs { ID = Employee.EmployeeID, Name = Employee.FirstName + " " + Employee.LastName, DateHired = Employee.DateHired }; return result.ToList(); } }
public List<ReportEmployee> Employee_byPositionReport(int positionid) { using(var context = new ToolsContext()) { if (positionid != 0) { var result = from Employee in context.Employees where Employee.Positions.PositionID == positionid orderby Employee.Positions.Description ascending select new ReportEmployee { Position = Employee.Positions.Description, Name = Employee.LastName + ", " + Employee.FirstName, Hired = Employee.DateHired, Release = Employee.DateReleased }; return result.ToList(); } else { var result2 = from Employee in context.Employees orderby Employee.Positions.Description ascending select new ReportEmployee { Position = Employee.Positions.Description, Name = Employee.LastName + ", " + Employee.FirstName, Hired = Employee.DateHired, Release = Employee.DateReleased }; return result2.ToList(); } } }