コード例 #1
0
 public List<Position> Position_List()
 {
     using (var context = new ToolsContext())
     {
         return context.Positions.ToList();
     }
 }
コード例 #2
0
        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
            }
        }
コード例 #3
0
 public List<Category> Categories_List()
 {
     using (ToolsContext context = new ToolsContext())
     {
         return context.Categories.ToList();
     }
 }
コード例 #4
0
 public Category Categories_FindbyID(int categoryid)
 {
     using (ToolsContext context = new ToolsContext())
     {
         return context.Categories.Find(categoryid);
     }
 }
コード例 #5
0
 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();
     }
 }
コード例 #6
0
 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
     }
 }
コード例 #7
0
 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
     }
 }
コード例 #8
0
 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
     }
 }
コード例 #9
0
 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();
     }
 }
コード例 #10
0
        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();
                }

            }
        }