public IHttpActionResult CreateBox(int boxKind, string userID)
        {
            if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Manager"))
            {
                BoxDAO boxDAO = new BoxDAO();
                try
                {
                    // delete accessory
                    DateTime now       = DateTime.Now;
                    string   tempDay   = (now.Day + "").Length == 1 ? '0' + (now.Day + "") : (now.Day + "");
                    string   tempMonth = (now.Month + "").Length == 1 ? '0' + (now.Month + "") : (now.Month + "");
                    string   tempYear  = (now.Year + "").Substring((now.Year + "").Length - 2);

                    string boxID = tempDay + tempMonth + tempYear;
                    Box    box   = (from b in db.Boxes.OrderByDescending(unit => unit.BoxPK)
                                    where b.BoxID.Contains(boxID)
                                    select b).FirstOrDefault();

                    if (box == null)
                    {
                        boxID += "001";
                    }
                    else
                    {
                        int    tempInt = Int32.Parse(box.BoxID.Substring(box.BoxID.Length - 6, 3)) + 1;
                        string tempStr = tempInt + "";
                        if (tempStr.Length == 1)
                        {
                            boxID += "00" + tempStr;
                        }
                        if (tempStr.Length == 2)
                        {
                            boxID += "0" + tempStr;
                        }
                        if (tempStr.Length == 3)
                        {
                            boxID += tempStr;
                        }
                    }
                    boxID += "box";
                    box    = new Box(boxID);
                    db.Boxes.Add(box);
                    db.SaveChanges();

                    box = boxDAO.GetBoxByBoxID(boxID);
                    boxDAO.CreateBox(boxKind, box.BoxPK);
                }
                catch (Exception e)
                {
                    return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
                }
                return(Content(HttpStatusCode.OK, "TẠO THÙNG THÀNH CÔNG!"));
            }
            else
            {
                return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!"));
            }
        }
        public double InBoxQuantity(string boxID, int itemPK, bool isRestored)
        {
            BoxDAO       boxDAO    = new BoxDAO();
            Box          box       = boxDAO.GetBoxByBoxID(boxID);
            StoredBox    storedBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
            List <Entry> entries   = (from e in db.Entries
                                      where e.StoredBoxPK == storedBox.StoredBoxPK && e.IsRestored == isRestored
                                      select e).ToList();

            return(EntriesQuantity(entries));
        }
        public TransferringSession CreateTransferingSession(string boxFromID, string boxToID, string userID)
        {
            TransferringSession result;
            BoxDAO boxDAO = new BoxDAO();

            try
            {
                Box       boxFrom  = boxDAO.GetBoxByBoxID(boxFromID);
                StoredBox sBoxFrom = boxDAO.GetStoredBoxbyBoxPK(boxFrom.BoxPK);
                Box       boxTo    = boxDAO.GetBoxByBoxID(boxToID);
                StoredBox sBoxTo   = boxDAO.GetStoredBoxbyBoxPK(boxTo.BoxPK);
                db.TransferringSessions.Add(new TransferringSession(sBoxFrom.StoredBoxPK, sBoxTo.StoredBoxPK, userID));
                db.SaveChanges();
                result = (from tSS in db.TransferringSessions.OrderByDescending(unit => unit.TransferingSessionPK)
                          select tSS).FirstOrDefault();
                return(result);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemple #4
0
 public IHttpActionResult DiscardInventory(string boxID, int itemPK, double discardedQuantity, bool isRestored, string userID, string comment)
 {
     if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Staff"))
     {
         BoxDAO            boxDAO            = new BoxDAO();
         StoringDAO        storingDAO        = new StoringDAO();
         DiscardingSession discardingSession = null;
         try
         {
             Box       box  = boxDAO.GetBoxByBoxID(boxID);
             StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
             if (sBox != null)
             {
                 List <Entry> entries = (from e in db.Entries
                                         where e.StoredBoxPK == sBox.StoredBoxPK && e.ItemPK == itemPK && e.IsRestored == isRestored
                                         select e).ToList();
                 discardingSession = storingDAO.CreateDiscardingSession(comment, false, userID);
                 if (discardedQuantity > storingDAO.EntriesQuantity(entries))
                 {
                     storingDAO.CreateDiscardEntry(sBox, itemPK, discardedQuantity, isRestored, discardingSession);
                 }
                 if (discardedQuantity < storingDAO.EntriesQuantity(entries))
                 {
                     storingDAO.CreateDiscardEntry(sBox, itemPK, discardedQuantity, isRestored, discardingSession);
                 }
                 else
                 {
                     return(Content(HttpStatusCode.Conflict, "SỐ LƯỢNG KHÔNG HỢP LỆ!"));
                 }
             }
             else
             {
                 if (discardingSession != null)
                 {
                     storingDAO.DeleteDiscardingSession(discardingSession.DiscardingSessionPK);
                 }
                 return(Content(HttpStatusCode.Conflict, "THÙNG KHÔNG HỢP LỆ!"));
             }
         }
         catch (Exception e)
         {
             return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
         }
         return(Content(HttpStatusCode.OK, "THAY ĐỔI KHO THÀNH CÔNG!"));
     }
     else
     {
         return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!"));
     }
 }
Exemple #5
0
        public IHttpActionResult StoreBoxBusiness(string boxID, string shelfID, string userID)
        {
            if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Staff"))
            {
                BoxDAO         boxDAO         = new BoxDAO();
                StoringDAO     storingItemDAO = new StoringDAO();
                StoredBox      storedBox      = null;
                StoringSession storingSession = null;
                try
                {
                    // khởi tạo
                    Box   box   = boxDAO.GetBoxByBoxID(boxID);
                    Shelf shelf = (from s in db.Shelves
                                   where s.ShelfID == shelfID && s.ShelfID != "InvisibleShelf"
                                   select s).FirstOrDefault();
                    if (boxDAO.GetUnstoredBoxbyBoxPK(box.BoxPK).IsIdentified&& !boxDAO.IsStored(box.BoxPK))
                    {
                        // chạy lệnh store box
                        storedBox      = storingItemDAO.CreateStoredBox(box.BoxPK, shelf.ShelfPK);
                        storingSession = storingItemDAO.CreateStoringSession(box.BoxPK, userID);
                        storingItemDAO.CreateEntriesUpdatePassedItem(box, storedBox, storingSession);
                    }
                    else
                    {
                        return(Content(HttpStatusCode.Conflict, "THÙNG KHÔNG HỢP LỆ"));
                    }
                }
                catch (Exception e)
                {
                    if (storedBox != null)
                    {
                        storingItemDAO.DeleteStoredBox(storedBox.StoredBoxPK);
                    }
                    if (storingSession != null)
                    {
                        storingItemDAO.DeleteStoringSession(storingSession.StoringSessionPK);
                    }
                    return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
                }


                return(Content(HttpStatusCode.OK, "STORE THÙNG THÀNH CÔNG"));
            }
            else
            {
                return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY"));
            }
        }
Exemple #6
0
 public IHttpActionResult MoveStoredBox(string boxID, string shelfID, string userID)
 {
     if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Staff"))
     {
         BoxDAO        boxDAO        = new BoxDAO();
         StoringDAO    storingDAO    = new StoringDAO();
         MovingSession movingSession = null;
         try
         {
             Box       box       = boxDAO.GetBoxByBoxID(boxID);
             StoredBox storedBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
             if (storedBox != null)
             {
                 Shelf shelf = boxDAO.GetShelfByShelfID(shelfID);
                 if (storedBox.ShelfPK != shelf.ShelfPK)
                 {
                     movingSession = storingDAO.CreateMovingSession(storedBox, shelf, userID);
                     storingDAO.UpdateStoredBoxShelfPK(storedBox.StoredBoxPK, shelf.ShelfPK);
                 }
                 else
                 {
                     return(Content(HttpStatusCode.Conflict, "KỆ KHÔNG HỢP LỆ!"));
                 }
             }
             else
             {
                 return(Content(HttpStatusCode.Conflict, "THÙNG KHÔNG HỢP LỆ!"));
             }
         }
         catch (Exception e)
         {
             if (movingSession != null)
             {
                 storingDAO.DeleteMovingSession(movingSession.MovingSessionPK);
             }
             return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
         }
         return(Content(HttpStatusCode.OK, "CHUYỂN THÙNG THÀNH CÔNG!"));
     }
     else
     {
         return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY!"));
     }
 }
Exemple #7
0
        public void CreateEntryReceiving(List <IssuingController.Client_Box_List> list, ReceivingSession receivingSession)
        {
            BoxDAO boxDAO = new BoxDAO();

            try
            {
                Dictionary <int, double> mapRestoredItems = new Dictionary <int, double>();
                foreach (var items in list)
                {
                    Box       box  = boxDAO.GetBoxByBoxID(items.BoxID);
                    StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
                    foreach (var item in items.ListItem)
                    {
                        RestoredItem restoredItem = db.RestoredItems.Find(item.RestoredItemPK);
                        if (!mapRestoredItems.ContainsKey(restoredItem.RestoredItemPK))
                        {
                            mapRestoredItems.Add(restoredItem.RestoredItemPK, item.PlacedQuantity);
                        }
                        else
                        {
                            mapRestoredItems[restoredItem.RestoredItemPK] += item.PlacedQuantity;
                        }
                        Accessory accessory = db.Accessories.Find(restoredItem.AccessoryPK);
                        Entry     entry     = new Entry(sBox, "Receiving", receivingSession.ReceivingSessionPK, true, item.PlacedQuantity, item.RestoredItemPK, accessory);
                        db.Entries.Add(entry);
                    }
                }
                foreach (var item in mapRestoredItems)
                {
                    RestoredItem restoredItem = db.RestoredItems.Find(item.Key);
                    if (item.Value != restoredItem.RestoredQuantity)
                    {
                        throw new Exception("TỔNG HÀNG LƯU KHO KHÔNG GIỐNG HÀNG ĐƯỢC TRẢ!");
                    }
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public IHttpActionResult GetItemByBoxID(string boxID)
        {
            BoxDAO     boxDAO     = new BoxDAO();
            StoringDAO storingDAO = new StoringDAO();

            try
            {
                Box box = boxDAO.GetBoxByBoxID(boxID);
                if (box != null)
                {
                    StoredBox   sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
                    UnstoredBox uBox = boxDAO.GetUnstoredBoxbyBoxPK(box.BoxPK);
                    // Nếu box chưa identify
                    if (uBox.IsIdentified)
                    {
                        // nếu box chưa được store
                        if (!(boxDAO.IsStored(box.BoxPK)))
                        {
                            List <Client_IdentifiedItemRead> client_IdentifiedItems = new List <Client_IdentifiedItemRead>();
                            List <IdentifiedItem>            identifiedItems;
                            identifiedItems = (from iI in db.IdentifiedItems.OrderByDescending(unit => unit.PackedItemPK)
                                               where iI.UnstoredBoxPK == uBox.UnstoredBoxPK
                                               select iI).ToList();

                            foreach (var identifiedItem in identifiedItems)
                            {
                                PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK);
                                // lấy pack ID
                                Pack pack = db.Packs.Find(packedItem.PackPK);

                                // lấy phụ liệu tương ứng
                                OrderedItem orderedItem = db.OrderedItems.Find(packedItem.OrderedItemPK);

                                Accessory accessory = db.Accessories.Find(orderedItem.AccessoryPK);
                                // lấy qualityState
                                ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems
                                                                 where cI.PackedItemPK == packedItem.PackedItemPK
                                                                 select cI).FirstOrDefault();
                                int?qualityState = null;
                                if (classifiedItem != null)
                                {
                                    qualityState = classifiedItem.QualityState;
                                }
                                client_IdentifiedItems.Add(new Client_IdentifiedItemRead(identifiedItem, accessory, pack.PackID, qualityState));
                            }
                            return(Content(HttpStatusCode.OK, client_IdentifiedItems));
                        }
                        else
                        {
                            Client_InBoxItems_Shelf <Client_Shelf> result;
                            Client_Shelf            client_Shelf;
                            List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>();

                            Shelf shelf = db.Shelves.Find(sBox.ShelfPK);
                            Row   row   = db.Rows.Find(shelf.RowPK);
                            client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID);

                            // Get list inBoxItem
                            List <Entry> entries = (from e in db.Entries
                                                    where e.StoredBoxPK == sBox.StoredBoxPK
                                                    select e).ToList();
                            HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >();
                            foreach (var entry in entries)
                            {
                                listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored));
                            }
                            foreach (var itemPK in listItemPK)
                            {
                                List <Entry> tempEntries = new List <Entry>();
                                foreach (var entry in entries)
                                {
                                    if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value)
                                    {
                                        tempEntries.Add(entry);
                                    }
                                }
                                if (tempEntries.Count > 0 && storingDAO.EntriesQuantity(tempEntries) > 0)
                                {
                                    Entry        entry = tempEntries[0];
                                    PassedItem   passedItem;
                                    RestoredItem restoredItem;
                                    if (entry.IsRestored)
                                    {
                                        restoredItem = db.RestoredItems.Find(entry.ItemPK);
                                        Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK);
                                        Accessory   accessory   = db.Accessories.Find(restoredItem.AccessoryPK);
                                        client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true));
                                    }
                                    else
                                    {
                                        passedItem = db.PassedItems.Find(entry.ItemPK);
                                        ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                                        PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                                        // lấy pack ID
                                        Pack pack = (from p in db.Packs
                                                     where p.PackPK == packedItem.PackPK
                                                     select p).FirstOrDefault();

                                        // lấy phụ liệu tương ứng
                                        OrderedItem orderedItem = (from oI in db.OrderedItems
                                                                   where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                                   select oI).FirstOrDefault();

                                        Accessory accessory = (from a in db.Accessories
                                                               where a.AccessoryPK == orderedItem.AccessoryPK
                                                               select a).FirstOrDefault();
                                        client_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false));
                                    }
                                }
                            }
                            result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems);
                            return(Content(HttpStatusCode.OK, result));
                        }
                    }
                    else
                    {
                        return(Content(HttpStatusCode.Conflict, "THÙNG NÀY CHƯA ĐƯỢC GHI NHẬN"));
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.Conflict, "ĐỐI TƯỢNG KHÔNG TỒN TẠI"));
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }
        }
Exemple #9
0
 public IHttpActionResult TransferStoredItems(string boxFromID, string boxToID, string userID, [FromBody] List <Client_ItemPK_TransferQuantity_IsRestored> list)
 {
     if (new ValidationBeforeCommandDAO().IsValidUser(userID, "Staff"))
     {
         BoxDAO              boxDAO              = new BoxDAO();
         StoringDAO          storingDAO          = new StoringDAO();
         TransferringSession transferringSession = null;
         try
         {
             if (boxFromID != boxToID)
             {
                 // lấy inBoxQuantity
                 Box       boxFrom  = boxDAO.GetBoxByBoxID(boxFromID);
                 StoredBox sBoxFrom = boxDAO.GetStoredBoxbyBoxPK(boxFrom.BoxPK);
                 Box       boxTo    = boxDAO.GetBoxByBoxID(boxToID);
                 StoredBox sBoxTo   = boxDAO.GetStoredBoxbyBoxPK(boxTo.BoxPK);
                 if (sBoxFrom == null)
                 {
                     return(Content(HttpStatusCode.Conflict, "BOX KHÔNG HỢP LỆ!"));
                 }
                 List <Entry> entries = (from e in db.Entries
                                         where e.StoredBoxPK == sBoxFrom.StoredBoxPK
                                         select e).ToList();
                 foreach (var item in list)
                 {
                     List <Entry> tempEntries = new List <Entry>();
                     foreach (var entry in entries)
                     {
                         if (entry.ItemPK == item.ItemPK)
                         {
                             tempEntries.Add(entry);
                         }
                     }
                     if (item.TransferQuantity > storingDAO.EntriesQuantity(tempEntries))
                     {
                         return(Content(HttpStatusCode.Conflict, "SỐ LƯỢNG KHÔNG HỢP LỆ!"));
                     }
                 }
                 transferringSession = storingDAO.CreateTransferingSession(boxFromID, boxToID, userID);
                 storingDAO.CreateInAndOutEntry(list, sBoxFrom, sBoxTo, transferringSession);
             }
             else
             {
                 return(Content(HttpStatusCode.Conflict, "BOX KHÔNG HỢP LỆ!"));
             }
             return(Content(HttpStatusCode.OK, "TRANSFER THÀNH CÔNG!"));
         }
         catch (Exception e)
         {
             if (transferringSession != null)
             {
                 storingDAO.DeleteTransferingSession(transferringSession.TransferingSessionPK);
             }
             return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
         }
     }
     else
     {
         return(Content(HttpStatusCode.Conflict, "BẠN KHÔNG CÓ QUYỀN ĐỂ THỰC HIỆN VIỆC NÀY"));
     }
 }
Exemple #10
0
        public IHttpActionResult GetIdentifyItemByBoxID(string boxID)
        {
            List <IdentifiedItem> identifiedItems;
            List <Client_IdentifiedItemStored> client_IdentifiedItems = new List <Client_IdentifiedItemStored>();
            BoxDAO          boxController   = new BoxDAO();
            IdentifyItemDAO identifyItemDAO = new IdentifyItemDAO();

            try
            {
                Box         box  = boxController.GetBoxByBoxID(boxID);
                UnstoredBox uBox = boxController.GetUnstoredBoxbyBoxPK(box.BoxPK);
                if (!boxController.IsStored(box.BoxPK) && uBox.IsIdentified == true)
                {
                    identifiedItems = (from iI in db.IdentifiedItems.OrderByDescending(unit => unit.PackedItemPK)
                                       where iI.UnstoredBoxPK == uBox.UnstoredBoxPK
                                       select iI).ToList();

                    foreach (var identifiedItem in identifiedItems)
                    {
                        PackedItem     packedItem     = db.PackedItems.Find(identifiedItem.PackedItemPK);
                        ClassifiedItem classifiedItem = (from cI in db.ClassifiedItems
                                                         where cI.PackedItemPK == packedItem.PackedItemPK
                                                         select cI).FirstOrDefault();
                        if (classifiedItem != null)
                        {
                            PassedItem passedItem = (from pI in db.PassedItems
                                                     where pI.ClassifiedItemPK == classifiedItem.ClassifiedItemPK
                                                     select pI).FirstOrDefault();
                            if (passedItem != null)
                            {
                                // lấy pack ID
                                Pack pack = (from p in db.Packs
                                             where p.PackPK == packedItem.PackPK
                                             select p).FirstOrDefault();

                                // lấy phụ liệu tương ứng
                                OrderedItem orderedItem = (from oI in db.OrderedItems
                                                           where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                           select oI).FirstOrDefault();

                                Accessory accessory = (from a in db.Accessories
                                                       where a.AccessoryPK == orderedItem.AccessoryPK
                                                       select a).FirstOrDefault();

                                client_IdentifiedItems.Add(new Client_IdentifiedItemStored(identifiedItem, accessory, pack,
                                                                                           identifyItemDAO.ActualQuantity(identifiedItem.IdentifiedItemPK)));
                            }
                            else
                            {
                                return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                            }
                        }
                        else
                        {
                            return(Content(HttpStatusCode.Conflict, "TỒN TẠI ÍT NHẤT MỘT CỤM PHỤ LIỆU KHÔNG ĐẠT!"));
                        }
                    }
                }
                else
                {
                    return(Content(HttpStatusCode.Conflict, "BOX ĐÃ ĐƯỢC STORE HOẶC CHƯA IDENTIFIED !"));
                }
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }

            return(Content(HttpStatusCode.OK, client_IdentifiedItems));
        }
Exemple #11
0
        public IHttpActionResult GetInBoxItemByBoxID(string boxID)
        {
            Client_InBoxItems_Shelf <Client_Shelf> result;
            Client_Shelf            client_Shelf;
            List <Client_InBoxItem> client_InBoxItems = new List <Client_InBoxItem>();
            BoxDAO     boxDAO     = new BoxDAO();
            StoringDAO storingDAO = new StoringDAO();

            try
            {
                // Get client Shelf
                Box       box  = boxDAO.GetBoxByBoxID(boxID);
                StoredBox sBox = boxDAO.GetStoredBoxbyBoxPK(box.BoxPK);
                if (sBox == null)
                {
                    return(Content(HttpStatusCode.Conflict, "BOX KHÔNG HỢP LỆ!"));
                }
                Shelf shelf = db.Shelves.Find(sBox.ShelfPK);
                Row   row   = db.Rows.Find(shelf.RowPK);
                client_Shelf = new Client_Shelf(shelf.ShelfID, row.RowID);

                // Get list inBoxItem
                List <Entry> entries = (from e in db.Entries
                                        where e.StoredBoxPK == sBox.StoredBoxPK
                                        select e).ToList();

                // Hiện thực cặp value ko được trùng 2 key là itemPK và isRestored
                HashSet <KeyValuePair <int, bool> > listItemPK = new HashSet <KeyValuePair <int, bool> >();
                foreach (var entry in entries)
                {
                    listItemPK.Add(new KeyValuePair <int, bool>(entry.ItemPK, entry.IsRestored));
                }
                foreach (var itemPK in listItemPK)
                {
                    List <Entry> tempEntries = new List <Entry>();
                    foreach (var entry in entries)
                    {
                        if (entry.ItemPK == itemPK.Key && entry.IsRestored == itemPK.Value)
                        {
                            tempEntries.Add(entry);
                        }
                    }
                    if (tempEntries.Count > 0)
                    {
                        Entry        entry = tempEntries[0];
                        PassedItem   passedItem;
                        RestoredItem restoredItem;
                        if (entry.IsRestored)
                        {
                            restoredItem = db.RestoredItems.Find(entry.ItemPK);
                            Restoration restoration = db.Restorations.Find(restoredItem.RestorationPK);
                            Accessory   accessory   = db.Accessories.Find(restoredItem.AccessoryPK);
                            client_InBoxItems.Add(new Client_InBoxItem(accessory, restoration.RestorationID, storingDAO.EntriesQuantity(tempEntries), restoredItem.RestoredItemPK, true));
                        }
                        else
                        {
                            passedItem = db.PassedItems.Find(entry.ItemPK);
                            ClassifiedItem classifiedItem = db.ClassifiedItems.Find(passedItem.ClassifiedItemPK);
                            PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                            // lấy pack ID
                            Pack pack = (from p in db.Packs
                                         where p.PackPK == packedItem.PackPK
                                         select p).FirstOrDefault();

                            // lấy phụ liệu tương ứng
                            OrderedItem orderedItem = (from oI in db.OrderedItems
                                                       where oI.OrderedItemPK == packedItem.OrderedItemPK
                                                       select oI).FirstOrDefault();

                            Accessory accessory = (from a in db.Accessories
                                                   where a.AccessoryPK == orderedItem.AccessoryPK
                                                   select a).FirstOrDefault();
                            client_InBoxItems.Add(new Client_InBoxItem(accessory, pack.PackID, storingDAO.EntriesQuantity(tempEntries), passedItem.PassedItemPK, false));
                        }
                    }
                }
                result = new Client_InBoxItems_Shelf <Client_Shelf>(client_Shelf, client_InBoxItems);
            }
            catch (Exception e)
            {
                return(Content(HttpStatusCode.Conflict, new Content_InnerException(e).InnerMessage()));
            }
            return(Content(HttpStatusCode.OK, result));
        }