public InventoryTransaction Map(tblInventoryTransaction tblInvTr)
        {
            var inv = _inventoryRepository.GetById(tblInvTr.InventoryId);
            InventoryTransaction accTr = new InventoryTransaction(tblInvTr.Id)
            {
                 CostCentreId = inv.Warehouse.Id, 
                Inventory = inv,
                NoItems = tblInvTr.NoItems.Value,
                NetValue = (decimal)tblInvTr.NetValue,
                GrossValue = (decimal)tblInvTr.GrossValue,
                DocumentType = (DocumentType)tblInvTr.DocumentType,
                DocumentId = tblInvTr.DocumentId,
                DateInserted = tblInvTr.DateInserted
            };
            accTr._SetDateCreated(tblInvTr.IM_DateCreated);
            accTr._SetDateLastUpdated(tblInvTr.IM_DateLastUpdated);
            accTr._SetStatus((EntityStatus)tblInvTr.IM_Status);

            return accTr;

        }
        public Guid Add(InventoryTransaction inventoryTransaction)
        {
            ValidationResultInfo vri = Validate(inventoryTransaction);
            if (!vri.IsValid)
            {
                throw new DomainValidationException(vri, "Failed To Validate InventoryTransaction");
            }
            tblInventoryTransaction tblInvTr = _ctx.tblInventoryTransaction.FirstOrDefault(n => n.Id == inventoryTransaction.Id); ;
            DateTime dt = DateTime.Now;
            if (tblInvTr == null)
            {
                tblInvTr = new tblInventoryTransaction();
                tblInvTr.Id = inventoryTransaction.Id;
                tblInvTr.IM_DateCreated = dt;
                tblInvTr.IM_Status = (int)EntityStatus.Active; //true;
                _ctx.tblInventoryTransaction.AddObject(tblInvTr);
                _log.DebugFormat("inventoryTransaction.Id == 0");
            }
            var entityStatus = (inventoryTransaction._Status == EntityStatus.New) ? EntityStatus.Active : inventoryTransaction._Status;
            if (tblInvTr.IM_Status != (int)entityStatus)
                tblInvTr.IM_Status = (int)inventoryTransaction._Status;
              


            tblInvTr.InventoryId = inventoryTransaction.Inventory.Id;
            tblInvTr.NoItems = inventoryTransaction.NoItems;
            tblInvTr.NetValue = inventoryTransaction.NetValue;
            tblInvTr.GrossValue = inventoryTransaction.GrossValue;
            tblInvTr.DocumentType = (int)inventoryTransaction.DocumentType;
            tblInvTr.DocumentId = inventoryTransaction.DocumentId;
            tblInvTr.DateInserted = inventoryTransaction.DateInserted;
            tblInvTr.IM_DateLastUpdated = dt;
            _log.DebugFormat("Saving/Updating InventoryTransaction");

            _ctx.SaveChanges();
            return tblInvTr.Id;
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the tblInventoryTransaction EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTotblInventoryTransaction(tblInventoryTransaction tblInventoryTransaction)
 {
     base.AddObject("tblInventoryTransaction", tblInventoryTransaction);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Create a new tblInventoryTransaction object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="inventoryId">Initial value of the InventoryId property.</param>
 /// <param name="netValue">Initial value of the NetValue property.</param>
 /// <param name="grossValue">Initial value of the GrossValue property.</param>
 /// <param name="documentType">Initial value of the DocumentType property.</param>
 /// <param name="documentId">Initial value of the DocumentId property.</param>
 /// <param name="dateInserted">Initial value of the DateInserted property.</param>
 /// <param name="iM_DateCreated">Initial value of the IM_DateCreated property.</param>
 /// <param name="iM_DateLastUpdated">Initial value of the IM_DateLastUpdated property.</param>
 /// <param name="iM_Status">Initial value of the IM_Status property.</param>
 public static tblInventoryTransaction CreatetblInventoryTransaction(global::System.Guid id, global::System.Guid inventoryId, global::System.Decimal netValue, global::System.Decimal grossValue, global::System.Int32 documentType, global::System.Guid documentId, global::System.DateTime dateInserted, global::System.DateTime iM_DateCreated, global::System.DateTime iM_DateLastUpdated, global::System.Int32 iM_Status)
 {
     tblInventoryTransaction tblInventoryTransaction = new tblInventoryTransaction();
     tblInventoryTransaction.Id = id;
     tblInventoryTransaction.InventoryId = inventoryId;
     tblInventoryTransaction.NetValue = netValue;
     tblInventoryTransaction.GrossValue = grossValue;
     tblInventoryTransaction.DocumentType = documentType;
     tblInventoryTransaction.DocumentId = documentId;
     tblInventoryTransaction.DateInserted = dateInserted;
     tblInventoryTransaction.IM_DateCreated = iM_DateCreated;
     tblInventoryTransaction.IM_DateLastUpdated = iM_DateLastUpdated;
     tblInventoryTransaction.IM_Status = iM_Status;
     return tblInventoryTransaction;
 }