Exemplo n.º 1
0
        private static List <Cart> GetCartsWithObjects(List <Cart> carts)
        {
            if (carts.Count == 0)
            {
                return(new List <Cart>());
            }
            List <long> empIds  = new List <long>();
            List <long> itemIds = new List <long>();

            foreach (Cart c in carts)
            {
                empIds.Add(c.Employee.EmpId);
                itemIds.Add(c.Item.ItemId);
            }

            if (empIds.Count == 0 || itemIds.Count == 0)
            {
                return(null);
            }


            List <Employee>  employees   = EmployeeDAO.GetEmployeesByIdList(empIds);
            List <Inventory> inventories = CatalogueDAO.GetCataloguesByIdList(itemIds);

            if (employees.Count != 0)
            {
                for (int i = 0; i < carts.Count; i++)
                {
                    carts[i].Employee = employees.Find(e => e.EmpId == carts[i].Employee.EmpId);
                    carts[i].Item     = inventories.Find(item => item.ItemId == carts[i].Item.ItemId);
                }
            }

            return(carts);
        }
Exemplo n.º 2
0
        public static List <Inventory> ShowItems(string description, string category)
        {
            List <Inventory> itemList = new List <Inventory>();

            if (category == "")
            {
                itemList = CatalogueDAO.GetAllCatalogue();
            }
            else
            {
                itemList = CatalogueDAO.GetCatalogueByCategory(category);
            }
            if (description == "")
            {
                return(itemList);
            }
            else
            {
                List <Inventory> searchList = new List <Inventory>();
                foreach (Inventory item in itemList)
                {
                    if (item.Description.ToUpper().Contains(description.ToUpper()))
                    {
                        searchList.Add(item);
                    }
                }
                return(searchList);
            }
        }
Exemplo n.º 3
0
 public ActionResult RemoveCatelogue(List <CatalogueDTO> catalog)
 {
     try
     {
         string message = CatalogueDAO.removeCatalogue(catalog);
         return(Ok(message));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 4
0
 public ActionResult GetAllCatelogue()
 {
     try
     {
         List <CatalogueDTO> catalogues = CatalogueDAO.GetAllCatalogue();
         return(Ok(catalogues));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 5
0
 public ActionResult UpdateCatelogue(CatalogueDTO catalog)
 {
     try
     {
         string message = CatalogueDAO.UpdateCatalogue(catalog);
         return(Ok(message));
     }
     catch (Exception)
     {
         return(BadRequest());
     }
 }
Exemplo n.º 6
0
        public static PurchaseOrder GetOrderDetails(string orderNumber)
        {
            PurchaseOrder order = PurchaseOrderDAO.GetOrderDetails(orderNumber);

            order.Employee    = EmployeeDAO.GetEmployeeById(order.EmployeeId);
            order.Supplier    = SupplierDAO.GetSupplierById(order.SupplierId);
            order.ItemDetails = PurchaseOrderDAO.GetItemsInPurchaseOrder(order.OrderId);

            foreach (var item in order.ItemDetails)
            {
                item.Item = CatalogueDAO.GetCatalogueById(item.ItemId);
                item.Item.ItemSuppliersDetails = SupplierDAO.GetItemSuppliersDetails(item.ItemId);
                item.Item.ItemSuppliersDetails.Supplier1Name = SupplierDAO.GetSupplierName(item.Item.ItemSuppliersDetails.Supplier1Id);
                item.Item.ItemSuppliersDetails.Supplier2Name = SupplierDAO.GetSupplierName(item.Item.ItemSuppliersDetails.Supplier2Id);
                item.Item.ItemSuppliersDetails.Supplier3Name = SupplierDAO.GetSupplierName(item.Item.ItemSuppliersDetails.Supplier3Id);
            }
            return(order);
        }
Exemplo n.º 7
0
        public static List <RequisitionDetails> DisplayRequisitionDetailsByReqId(long reqId)
        {
            List <RequisitionDetails> list = RequisitionDAO.GetRequisitionDetailsByReqId(reqId);
            List <long> inventoryIds       = new List <long>();

            foreach (RequisitionDetails req in list)
            {
                inventoryIds.Add(req.Item.ItemId);
                //req.Employee = EmployeeDAO.GetEmployeeById(req.Employee.EmpId);
            }

            List <Inventory> items = CatalogueDAO.GetInventoriesByIdList(inventoryIds);

            if (items.Count != 0)
            {
                for (int i = 0; i < list.Count; i++)
                {
                    list[i].Item = items.Find(item => item.ItemId == list[i].Item.ItemId);
                }
            }
            return(list);
        }
Exemplo n.º 8
0
 public static List <string> GetALLCategories()
 {
     return(CatalogueDAO.GetAllCategories());
 }
Exemplo n.º 9
0
 public static List <string> GetAllUnits()
 {
     return(CatalogueDAO.GetAllUnits());
 }
Exemplo n.º 10
0
 public static void UpdateCatalogue(Inventory catalogue)
 {
     CatalogueDAO.UpdateCatalogue(catalogue);
 }
Exemplo n.º 11
0
 public static long CreateCatalogueDetaills(Inventory catalogue)
 {
     return(CatalogueDAO.CreateCatalogue(catalogue));
 }
Exemplo n.º 12
0
 public static void DeleteCatalogue(long itemId)
 {
     CatalogueDAO.DeleteCatalogue(itemId);
 }
Exemplo n.º 13
0
 public static Inventory GetCatalogueById(long itemId)
 {
     return(CatalogueDAO.GetCatalogueById(itemId));
 }
Exemplo n.º 14
0
        //public static bool VerifyExist(string itemCode)
        //{
        //    List<string> catalogueCodes = CatalogueDAO.GetAllItemCodes();
        //    foreach(string code in catalogueCodes)
        //    {
        //        if(itemCode == code)
        //        {
        //            return true;
        //        }
        //    }
        //    return false;
        //}

        public static List <Inventory> GetAllCatalogue()
        {
            return(CatalogueDAO.GetAllCatalogue());
        }