public ActionResult ReceiveProduct(long dispatchId)
 {
     try
     {
         int branchId = Convert.ToInt32(Session["BranchId"]);
         var user     = (ViewUser)Session["user"];
         ViewDispatchModel dispatchModel = _iInventoryManager.GetDispatchByDispatchId(dispatchId);
         dispatchModel.ReceiveByUserId = user.UserId;
         var receivesProductList = _iInventoryManager.GetAllReceiveableProductToBranchByDispatchId(dispatchId, branchId);
         dispatchModel.DispatchModels = receivesProductList;
         var filePath           = GetReceiveProductFilePath(dispatchId, branchId);
         var receiveProductList = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();
         dispatchModel.Quantity        = receiveProductList.Count;
         dispatchModel.ToBranchId      = Convert.ToInt32(Session["BranchId"]);
         dispatchModel.ScannedProducts = receiveProductList;
         int result = _iInventoryManager.ReceiveProduct(dispatchModel);
         if (result > 0)
         {
             System.IO.File.Create(filePath).Close();
             TempData["ReceiveMessage"] = "Received Successfully!";
         }
         else
         {
             TempData["ReceiveMessage"] = "Failed to Receive";
         }
         return(RedirectToAction("Receive"));
     }
     catch (Exception exception)
     {
         Log.WriteErrorLog(exception);
         return(PartialView("_ErrorPartial", exception));
     }
 }
Exemple #2
0
        public ActionResult ReceiveProduct(long tripId)
        {
            int branchId = Convert.ToInt32(Session["BranchId"]);
            var user     = (ViewUser)Session["user"];
            ViewDispatchModel dispatchModel = _iInventoryManager.GetDispatchByTripId(tripId);

            dispatchModel.ReceiveByUserId = user.UserId;
            var receivesProductList = _iInventoryManager.GetAllReceiveableProductToBranchByTripId(tripId, branchId);

            dispatchModel.DispatchModels = receivesProductList;
            string fileName           = "Received_Product_For_" + tripId + branchId;
            var    filePath           = Server.MapPath("~/Files/" + fileName);
            var    receiveProductList = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();

            dispatchModel.Quantity        = receiveProductList.Count;
            dispatchModel.ToBranchId      = Convert.ToInt32(Session["BranchId"]);
            dispatchModel.ScannedProducts = receiveProductList;
            int result = _iInventoryManager.ReceiveProduct(dispatchModel);

            if (result > 0)
            {
                System.IO.File.Create(filePath).Close();
                TempData["ReceiveMessage"] = "Received Successfully!";
            }
            else
            {
                TempData["ReceiveMessage"] = "Failed to Receive";
            }
            return(RedirectToAction("Receive"));
        }
 public int ReceiveProduct(ViewDispatchModel model)
 {
     return(_iInventoryGateway.ReceiveProduct(model));
 }