コード例 #1
0
        protected override void RemoveExisting(Drop <ContainerDestination> drop)
        {
            var existingPosition = Drops.FirstOrDefault(x => x.Bay == drop.Bay && x.Row == drop.Row);

            if (existingPosition != null)
            {
                Drops.Remove(existingPosition);

                if (existingPosition.Data.Container.Size == ContainerSize.FortyFoot)
                {
                    string rowNumber      = existingPosition.Row;
                    string rightBayNumber = (int.Parse(existingPosition.Bay) + 1).ToString();
                    string leftBayNumber  = (int.Parse(existingPosition.Bay) - 1).ToString();

                    existingPosition = Drops.FirstOrDefault(x => x.Bay == rightBayNumber && x.Row == rowNumber);
                    if (existingPosition == null)
                    {
                        existingPosition = Drops.FirstOrDefault(x => x.Bay == leftBayNumber && x.Row == rowNumber);
                    }

                    Drops.Remove(existingPosition);
                }
            }

            foreach (var objectDrop in Drops.Where(x => x.Data.GetHashCode() == drop.Data.GetHashCode()).ToArray())
            {
                Drops.Remove(objectDrop);
            }
        }
コード例 #2
0
        public async Task <bool> DeleteDrop(Guid?dropId)
        {
            if (dropId.HasValue)
            {
                var resp = await _dropClient.DeleteDrop(dropId.Value, _deviceService.DeviceId);

                if (resp.IsSuccessStatusCode)
                {
                    //remove drop from cache of all drops
                    var dropToDelete = Drops.FirstOrDefault(x => x.Id == dropId);
                    if (dropToDelete != null)
                    {
                        Drops.Remove(dropToDelete);
                    }

                    //remove drop from cache of own drops
                    dropToDelete = OwnDrops.FirstOrDefault(x => x.Id == dropId);
                    if (dropToDelete != null)
                    {
                        OwnDrops.Remove(dropToDelete);
                    }
                }
                return(resp.IsSuccessStatusCode);
            }
            return(false);
        }
コード例 #3
0
        protected virtual void RemoveExisting(Drop <T> drop)
        {
            var existingDrop     = Drops.FirstOrDefault(x => x.Data.GetHashCode() == drop.Data.GetHashCode());
            var existingPosition = Drops.FirstOrDefault(x => x.Bay == drop.Bay && x.Row == drop.Row);

            if (existingPosition != null)
            {
                Drops.Remove(existingPosition);
            }
            if (existingDrop != null)
            {
                Drops.Remove(existingDrop);
            }
        }
コード例 #4
0
        public async Task <Drop> GetDrop(Guid?id)
        {
            if (id.HasValue)
            {
                var result = Drops.FirstOrDefault(x => x.Id == id);
                if (result == null)
                {
                    result = await _dropClient.GetDrop(id.Value);

                    if (result != null)
                    {
                        Drops.Add(result);
                    }
                }
                return(result);
            }
            return(null);
        }