public virtual PicklistStateMergePatchedDto ToPicklistStateMergePatchedDto(IPicklistStateMergePatched e)
        {
            var dto = new PicklistStateMergePatchedDto();

            dto.PicklistEventId      = e.PicklistEventId;
            dto.CreatedAt            = e.CreatedAt;
            dto.CreatedBy            = e.CreatedBy;
            dto.CommandId            = e.CommandId;
            dto.Description          = e.Description;
            dto.FacilityId           = e.FacilityId;
            dto.ShipmentMethodTypeId = e.ShipmentMethodTypeId;
            dto.StatusId             = e.StatusId;
            dto.PicklistDate         = e.PicklistDate;
            dto.PickwaveId           = e.PickwaveId;
            dto.Active = e.Active;
            dto.IsPropertyDescriptionRemoved          = e.IsPropertyDescriptionRemoved;
            dto.IsPropertyFacilityIdRemoved           = e.IsPropertyFacilityIdRemoved;
            dto.IsPropertyShipmentMethodTypeIdRemoved = e.IsPropertyShipmentMethodTypeIdRemoved;
            dto.IsPropertyStatusIdRemoved             = e.IsPropertyStatusIdRemoved;
            dto.IsPropertyPicklistDateRemoved         = e.IsPropertyPicklistDateRemoved;
            dto.IsPropertyPickwaveIdRemoved           = e.IsPropertyPickwaveIdRemoved;
            dto.IsPropertyActiveRemoved = e.IsPropertyActiveRemoved;
            var picklistRoleEvents = new List <PicklistRoleStateCreatedOrMergePatchedOrRemovedDto>();

            foreach (var ee in e.PicklistRoleEvents)
            {
                PicklistRoleStateCreatedOrMergePatchedOrRemovedDto eeDto = PicklistRoleStateEventDtoConverter.ToPicklistRoleStateEventDto(ee);
                picklistRoleEvents.Add(eeDto);
            }
            dto.PicklistRoleEvents = picklistRoleEvents.ToArray();


            return(dto);
        }
Exemplo n.º 2
0
        protected virtual IPicklistStateMergePatched Map(IMergePatchPicklist c)
        {
            var stateEventId             = new PicklistEventId(c.PicklistId, c.Version);
            IPicklistStateMergePatched e = NewPicklistStateMergePatched(stateEventId);

            e.Description          = c.Description;
            e.FacilityId           = c.FacilityId;
            e.ShipmentMethodTypeId = c.ShipmentMethodTypeId;
            e.StatusId             = c.StatusId;
            e.PicklistDate         = c.PicklistDate;
            e.PickwaveId           = c.PickwaveId;
            e.Active = c.Active;
            e.IsPropertyDescriptionRemoved          = c.IsPropertyDescriptionRemoved;
            e.IsPropertyFacilityIdRemoved           = c.IsPropertyFacilityIdRemoved;
            e.IsPropertyShipmentMethodTypeIdRemoved = c.IsPropertyShipmentMethodTypeIdRemoved;
            e.IsPropertyStatusIdRemoved             = c.IsPropertyStatusIdRemoved;
            e.IsPropertyPicklistDateRemoved         = c.IsPropertyPicklistDateRemoved;
            e.IsPropertyPickwaveIdRemoved           = c.IsPropertyPickwaveIdRemoved;
            e.IsPropertyActiveRemoved = c.IsPropertyActiveRemoved;

            e.CommandId = c.CommandId;


            e.CreatedBy = (string)c.RequesterId;
            e.CreatedAt = ApplicationContext.Current.TimestampService.Now <DateTime>();

            var version = c.Version;

            foreach (IPicklistRoleCommand innerCommand in c.PicklistRoleCommands)
            {
                ThrowOnInconsistentCommands(c, innerCommand);

                IPicklistRoleEvent innerEvent = Map(innerCommand, c, version, _state);
                e.AddPicklistRoleEvent(innerEvent);
            }


            return(e);
        }
Exemplo n.º 3
0
 void IPicklistState.When(IPicklistStateMergePatched e)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 4
0
        public virtual void MergePatch(IMergePatchPicklist c)
        {
            IPicklistStateMergePatched e = Map(c);

            Apply(e);
        }
Exemplo n.º 5
0
        public virtual void When(IPicklistStateMergePatched e)
        {
            ThrowOnWrongEvent(e);

            if (e.Description == null)
            {
                if (e.IsPropertyDescriptionRemoved)
                {
                    this.Description = default(string);
                }
            }
            else
            {
                this.Description = e.Description;
            }

            if (e.FacilityId == null)
            {
                if (e.IsPropertyFacilityIdRemoved)
                {
                    this.FacilityId = default(string);
                }
            }
            else
            {
                this.FacilityId = e.FacilityId;
            }

            if (e.ShipmentMethodTypeId == null)
            {
                if (e.IsPropertyShipmentMethodTypeIdRemoved)
                {
                    this.ShipmentMethodTypeId = default(string);
                }
            }
            else
            {
                this.ShipmentMethodTypeId = e.ShipmentMethodTypeId;
            }

            if (e.StatusId == null)
            {
                if (e.IsPropertyStatusIdRemoved)
                {
                    this.StatusId = default(string);
                }
            }
            else
            {
                this.StatusId = e.StatusId;
            }

            if (e.PicklistDate == null)
            {
                if (e.IsPropertyPicklistDateRemoved)
                {
                    this.PicklistDate = default(DateTime?);
                }
            }
            else
            {
                this.PicklistDate = e.PicklistDate;
            }

            if (e.PickwaveId == null)
            {
                if (e.IsPropertyPickwaveIdRemoved)
                {
                    this.PickwaveId = default(long?);
                }
            }
            else
            {
                this.PickwaveId = e.PickwaveId;
            }

            if (e.Active == null)
            {
                if (e.IsPropertyActiveRemoved)
                {
                    this.Active = default(bool);
                }
            }
            else
            {
                this.Active = (e.Active != null && e.Active.HasValue) ? e.Active.Value : default(bool);
            }


            this.UpdatedBy = e.CreatedBy;
            this.UpdatedAt = e.CreatedAt;


            foreach (IPicklistRoleEvent innerEvent in e.PicklistRoleEvents)
            {
                IPicklistRoleState innerState = this.PicklistRoles.Get(innerEvent.GlobalId.PartyRoleId);

                innerState.Mutate(innerEvent);
                var removed = innerEvent as IPicklistRoleStateRemoved;
                if (removed != null)
                {
                    this.PicklistRoles.Remove(innerState);
                }
            }
        }