public ActionResult SaveDispatchInformation(long tripId)
        {
            try
            {
                var    user            = (ViewUser)Session["user"];
                string fileName        = "Deliverable_Product_For_" + user.UserId + "_" + tripId;
                var    filePath        = Server.MapPath("~/Files/" + fileName);
                var    scannedProducts = _iProductManager.GetScannedProductListFromTextFile(filePath).ToList();

                if (scannedProducts.Count > 0)
                {
                    var products         = _iProductManager.GetDeliverableProductListByTripId(tripId);
                    int dispatchByUserId = ((ViewUser)Session["user"]).UserId;
                    int companyId        = Convert.ToInt32(Session["CompanyId"]);
                    var viewTrip         = _iInventoryManager.GetAllTrip().ToList().Find(n => n.TripId == tripId);
                    viewTrip.Status = 2;
                    var tripQty     = products.Sum(n => n.Quantity);
                    var deliveryQty = scannedProducts.Count;

                    if (tripQty != deliveryQty)
                    {
                        viewTrip.Status = 1;
                    }

                    DispatchModel model = new DispatchModel
                    {
                        DispatchByUserId = dispatchByUserId,
                        CompanyId        = companyId,
                        TripModel        = viewTrip,
                        DispatchDate     = DateTime.Now,
                        ScannedProducts  = scannedProducts,
                        DispatchModels   = products
                    };

                    string result = _iFactoryDeliveryManager.SaveDispatchInformation(model);
                    if (result.StartsWith("Sa"))
                    {
                        System.IO.File.Create(filePath).Close();
                        //---------------Send mail to branch before redirect--------------
                        TempData["Dispatched"] = result;
                        return(RedirectToAction("DeliverableTransferIssueList"));
                    }
                    return(RedirectToAction("Delivery", new { id = tripId }));
                }

                return(RedirectToAction("Delivery", new { id = tripId }));
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                return(PartialView("_ErrorPartial", exception));
            }
        }