예제 #1
0
        public HttpResponseMessage updateStockIn(String id, Models.TrnStockIn stockIn)
        {
            try
            {
                var userId = (from d in db.MstUsers where d.UserId == User.Identity.GetUserId() select d.Id).SingleOrDefault();

                var stockIns = from d in db.TrnStockIns where d.Id == Convert.ToInt32(id) select d;
                if (stockIns.Any())
                {
                    var updateStockIn = stockIns.FirstOrDefault();
                    updateStockIn.BranchId        = stockIn.BranchId;
                    updateStockIn.INNumber        = stockIn.INNumber;
                    updateStockIn.INDate          = Convert.ToDateTime(stockIn.INDate);
                    updateStockIn.AccountId       = stockIn.AccountId;
                    updateStockIn.ArticleId       = stockIn.ArticleId;
                    updateStockIn.Particulars     = stockIn.Particulars;
                    updateStockIn.ManualINNumber  = stockIn.ManualINNumber;
                    updateStockIn.IsProduced      = stockIn.IsProduced;
                    updateStockIn.PreparedById    = stockIn.PreparedById;
                    updateStockIn.CheckedById     = stockIn.CheckedById;
                    updateStockIn.ApprovedById    = stockIn.ApprovedById;
                    updateStockIn.IsLocked        = true;
                    updateStockIn.UpdatedById     = userId;
                    updateStockIn.UpdatedDateTime = DateTime.Now;

                    db.SubmitChanges();

                    inventory.insertINInventory(Convert.ToInt32(id), stockIn.IsProduced);
                    journal.insertINJournal(Convert.ToInt32(id));

                    return(Request.CreateResponse(HttpStatusCode.OK));
                }
                else
                {
                    return(Request.CreateResponse(HttpStatusCode.NotFound));
                }
            }
            catch
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest));
            }
        }