Exemplo n.º 1
0
        public Error InsertOrUpdateShipmentContent(ShipmentContentModel content, UserModel user, string lockGuid)
        {
            var error = validateShipmentContentModel(content);

            if (!error.IsError)
            {
                // Check that the lock is still current
                if (!db.IsLockStillValid(typeof(ShipmentContent).ToString(), content.Id, lockGuid))
                {
                    error.SetError(EvolutionResources.errRecordChangedByAnotherUser, "OrderNumber");
                }
                else
                {
                    ShipmentContent temp = null;
                    if (content.Id != 0)
                    {
                        temp = db.FindShipmentContent(content.Id);
                    }
                    if (temp == null)
                    {
                        temp = new ShipmentContent();
                    }

                    mapToEntity(content, temp);

                    db.InsertOrUpdateShipmentContent(temp);
                    content.Id = temp.Id;
                }
            }
            return(error);
        }
Exemplo n.º 2
0
        public ShipmentContentModel MapToModel(ShipmentContent item)
        {
            var newItem = Mapper.Map <ShipmentContent, ShipmentContentModel>(item);

            newItem.CBMEstimate = 0;
            if (item.PurchaseOrderHeader != null)
            {
                newItem.OrderNumber = item.PurchaseOrderHeader.OrderNumber;

                foreach (var pod in item.PurchaseOrderHeader.PurchaseOrderDetails)
                {
                    if (pod.OrderQty != null && pod.Product != null && pod.Product.UnitCBM != null)
                    {
                        newItem.CBMEstimate += (double)pod.OrderQty.Value * pod.Product.UnitCBM.Value;
                    }
                }
            }
            if (item.Supplier != null)
            {
                newItem.SupplierName = item.Supplier.Name;
            }

            return(newItem);
        }
Exemplo n.º 3
0
 private void mapToEntity(ShipmentContentModel model, ShipmentContent entity)
 {
     Mapper.Map <ShipmentContentModel, ShipmentContent>(model, entity);
 }