public int SaveTransferRequisitionInfo(TransferRequisition aRequisitionModel)
        {
            int maxTrNo = _iProductGateway.GetMaxTransferRequisitionNoOfCurrentYear();

            aRequisitionModel.TransferRequisitionRef = GenerateTransferRequisitionRef(maxTrNo);
            return(_iProductGateway.SaveTransferRequisitionInfo(aRequisitionModel));
        }
        public ActionResult Requisition(FormCollection collection)
        {
            try
            {
                var            user        = (ViewUser)Session["user"];
                var            filePath    = GetTempRequisitonFIilePath();
                List <Product> productList = GetProductFromXmalFile(filePath).ToList();

                if (productList.Count != 0)
                {
                    var xmlData    = XDocument.Load(filePath);
                    int toBranchId = Convert.ToInt32(collection["ToBranchId"]);

                    TransferRequisition aRequisitionModel = new TransferRequisition
                    {
                        Products = productList,
                        RequisitionToBranchId   = toBranchId,
                        RequisitionByBranchId   = Convert.ToInt32(Session["BranchId"]),
                        RequisitionByUserId     = user.UserId,
                        TransferRequisitionDate = Convert.ToDateTime(collection["RequisitionDate"])
                    };
                    int rowAffected = _iProductManager.SaveTransferRequisitionInfo(aRequisitionModel);
                    if (rowAffected > 0)
                    {
                        xmlData.Root?.Elements().Remove();
                        xmlData.Save(filePath);
                        TempData["message"] = "Requisition Create  Successfully!";
                    }
                    else
                    {
                        TempData["message"] = "Failed to create Requisition!";
                    }
                }

                return(View());
            }
            catch (Exception exception)
            {
                Log.WriteErrorLog(exception);
                return(PartialView("_ErrorPartial", exception));
            }
        }