public HttpResponseMessage postStockInLine(Entities.TrnStockInLine stockInLine)
        {
            try
            {
                Data.TrnStockInLine newStockInLine = new Data.TrnStockInLine();
                newStockInLine.StockInId      = stockInLine.StockInId;
                newStockInLine.ItemId         = stockInLine.ItemId;
                newStockInLine.UnitId         = stockInLine.UnitId;
                newStockInLine.Quantity       = stockInLine.Quantity;
                newStockInLine.Cost           = stockInLine.Cost;
                newStockInLine.Amount         = stockInLine.Amount;
                newStockInLine.ExpiryDate     = stockInLine.ExpiryDate;
                newStockInLine.LotNumber      = stockInLine.LotNumber;
                newStockInLine.AssetAccountId = stockInLine.AssetAccountId;
                db.TrnStockInLines.InsertOnSubmit(newStockInLine);
                db.SubmitChanges();

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, "Something's wrong from the server."));
            }
        }
        public HttpResponseMessage putStockInLine(String id, Entities.TrnStockInLine newStockInLine)
        {
            try
            {
                var stockInLine = from d in db.TrnStockInLines where d.Id == Convert.ToInt32(id) select d;
                if (stockInLine.Any())
                {
                    //var userId = (from d in db.MstUsers where d.AspNetUserId == User.Identity.GetUserId() select d).FirstOrDefault().Id;

                    var updateStockInLine = stockInLine.FirstOrDefault();
                    updateStockInLine.StockInId   = newStockInLine.StockInId;
                    updateStockInLine.ItemId      = newStockInLine.ItemId;
                    updateStockInLine.UnitId      = newStockInLine.UnitId;
                    updateStockInLine.Quantity    = newStockInLine.Quantity;
                    updateStockInLine.Cost        = newStockInLine.Cost;
                    updateStockInLine.Amount      = newStockInLine.Amount;
                    newStockInLine.ExpiryDate     = newStockInLine.ExpiryDate;
                    newStockInLine.LotNumber      = newStockInLine.LotNumber;
                    newStockInLine.AssetAccountId = newStockInLine.AssetAccountId;
                    db.TrnStockInLines.InsertOnSubmit(updateStockInLine);
                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }
        public HttpResponseMessage putStockInLine(String id, Entities.TrnStockInLine stockInLine)
        {
            try
            {
                var stockInLines = from d in db.TrnStockInLines where d.Id == Convert.ToInt32(id) select d;
                if (stockInLines.Any())
                {
                    var updateStockInLine = stockInLines.FirstOrDefault();
                    updateStockInLine.StockInId      = stockInLine.StockInId;
                    updateStockInLine.ItemId         = stockInLine.ItemId;
                    updateStockInLine.UnitId         = stockInLine.UnitId;
                    updateStockInLine.Quantity       = stockInLine.Quantity;
                    updateStockInLine.Cost           = stockInLine.Cost;
                    updateStockInLine.Amount         = stockInLine.Amount;
                    updateStockInLine.ExpiryDate     = stockInLine.ExpiryDate;
                    updateStockInLine.LotNumber      = stockInLine.LotNumber;
                    updateStockInLine.AssetAccountId = stockInLine.AssetAccountId;
                    db.SubmitChanges();

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch (Exception e)
            {
                // Debug.WriteLine(e);
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }