public HttpResponseMessage updateStockTransfer(String id, Models.TrnStockTransfer stockTransfer)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var stockTransfers = from d in db.TrnStockTransfers where d.Id == Convert.ToInt32(id) select d;
                if (stockTransfers.Any())
                {
                    var updateStockTransfer = stockTransfers.FirstOrDefault();
                    updateStockTransfer.BranchId        = stockTransfer.BranchId;
                    updateStockTransfer.STNumber        = stockTransfer.STNumber;
                    updateStockTransfer.STDate          = Convert.ToDateTime(stockTransfer.STDate);
                    updateStockTransfer.ToBranchId      = stockTransfer.ToBranchId;
                    updateStockTransfer.Particulars     = stockTransfer.Particulars;
                    updateStockTransfer.ArticleId       = stockTransfer.ArticleId;
                    updateStockTransfer.ManualSTNumber  = stockTransfer.ManualSTNumber;
                    updateStockTransfer.PreparedById    = stockTransfer.PreparedById;
                    updateStockTransfer.CheckedById     = stockTransfer.CheckedById;
                    updateStockTransfer.ApprovedById    = stockTransfer.ApprovedById;
                    updateStockTransfer.IsLocked        = true;
                    updateStockTransfer.UpdatedById     = userId;
                    updateStockTransfer.UpdatedDateTime = DateTime.Now;
                    db.SubmitChanges();

                    inventory.InsertSTInventory(Convert.ToInt32(id));
                    journal.insertSTJournal(Convert.ToInt32(id));

                    // Check for negative inventory
                    bool foundNegativeQuantity = false;
                    if (updateStockTransfer.TrnStockTransferItems.Any())
                    {
                        foreach (var stockTransferItem in updateStockTransfer.TrnStockTransferItems)
                        {
                            if (stockTransferItem.MstArticle.IsInventory)
                            {
                                var mstArticleInventory = from d in db.MstArticleInventories
                                                          where d.TrnStockTransferItems.Contains(stockTransferItem)
                                                          select d;

                                if (mstArticleInventory.Any())
                                {
                                    if (stockTransferItem.MstArticleInventory.Quantity < 0)
                                    {
                                        foundNegativeQuantity = true;
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (!foundNegativeQuantity)
                    {
                        return(Request.CreateResponse(HttpStatusCode.OK));
                    }
                    else
                    {
                        inventory.deleteSTInventory(Convert.ToInt32(id));
                        journal.deleteSTJournal(Convert.ToInt32(id));

                        updateStockTransfer.IsLocked = false;
                        db.SubmitChanges();

                        return(Request.CreateResponse(HttpStatusCode.BadRequest, "Negative Inventory Found!"));
                    }
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }