Ejemplo n.º 1
0
        protected override void PersistNewItem(IShipment entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new ShipmentFactory();
            var dto     = factory.BuildDto(entity);

            Database.Insert(dto);
            entity.Key = dto.Key;
            entity.ResetDirtyProperties();
        }
Ejemplo n.º 2
0
        protected override void PersistUpdatedItem(IShipment entity)
        {
            ((Entity)entity).UpdatingEntity();

            var factory = new ShipmentFactory();
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Persists a new shipment record.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistNewItem(IShipment entity)
        {
            ((Entity)entity).AddingEntity();

            var factory = new ShipmentFactory();
            var dto     = factory.BuildDto(entity);

            Database.Insert(dto);
            entity.Key = dto.Key;

            foreach (var item in entity.Items.ToArray())
            {
                ((IOrderLineItem)item).ShipmentKey = entity.Key;
                _orderLineItemRepository.SaveLineItem((IOrderLineItem)item);
            }

            entity.ResetDirtyProperties();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Persists an updated shipment record.
        /// </summary>
        /// <param name="entity">
        /// The entity.
        /// </param>
        protected override void PersistUpdatedItem(IShipment entity)
        {
            var query = Querying.Query <IOrderLineItem> .Builder.Where(x => x.ShipmentKey == entity.Key);

            var existing = _orderLineItemRepository.GetByQuery(query);

            var removers = existing.Where(x => entity.Items.All(y => y.Key != x.Key));

            foreach (var remove in removers)
            {
                ((IOrderLineItem)remove).ShipmentKey = null;
                _orderLineItemRepository.SaveLineItem((IOrderLineItem)remove);
            }

            ((Entity)entity).UpdatingEntity();

            var factory = new ShipmentFactory();
            var dto     = factory.BuildDto(entity);

            Database.Update(dto);

            entity.ResetDirtyProperties();
        }