Esempio n. 1
0
        public void MoveItem(ContainablePart item, ContainerPart targetContainer, int?position = null)
        {
            var commonPart = item.As <CommonPart>();

            if (commonPart == null)
            {
                throw new ArgumentException("Cannot move content that have no CommonPart", "item");
            }

            var previousContainer = commonPart.Container != null?commonPart.Container.As <ContainerPart>() : default(ContainerPart);

            commonPart.Container = targetContainer;

            if (previousContainer != null && previousContainer.Id != targetContainer.Id)
            {
                UpdateItemCount(previousContainer);
            }

            if (position != null)
            {
                item.Position = position.Value;
            }

            UpdateItemCount(targetContainer);
            UpdateItemPath(item.ContentItem);
        }
Esempio n. 2
0
 public void UpdateItemCount(ContainerPart container)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     container.ItemCount = CountContentItems(container.Id, VersionOptions.Published);
 }
Esempio n. 3
0
        /// <summary>
        /// convert containerPart to view model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public ContainerPartViewModel ConvertToView(ContainerPart containerPart)
        {
            ContainerPartViewModel model = new ContainerPartViewModel();

            var _containerRepository    = new ContainerRepository();
            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _foundryOrderRepository = new FoundryOrderRepository();

            var container        = _containerRepository.GetContainer(containerPart.ContainerId);
            var foundryOrderPart = _foundryOrderRepository.GetFoundryOrderParts().FirstOrDefault(x => x.FoundryOrderPartId == containerPart.FoundryOrderPartId);
            var part             = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart     = _dynamicsPartRepository.GetPartMaster(part != null && !string.IsNullOrEmpty(part.Number) ? part.Number : null);
            var foundryOrder     = _foundryOrderRepository.GetFoundryOrder((foundryOrderPart != null) ? foundryOrderPart.FoundryOrderId : Guid.Empty);

            model.FoundryOrderPartId = containerPart.FoundryOrderPartId;
            model.ContainerPartId    = containerPart.ContainerPartId;
            model.ContainerId        = containerPart.ContainerId;
            model.PartId             = (part != null) ? part.PartId : Guid.Empty;
            model.ContainerNumber    = (container != null) ? container.Number : "N/A";
            model.PartNumber         = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.FoundryOrderId     = (foundryOrder != null) ? foundryOrder.FoundryOrderId : Guid.Empty;
            model.OrderNumber        = (foundryOrder != null && !string.IsNullOrEmpty(foundryOrder.Number)) ? foundryOrder.Number : "N/A";
            model.PalletNumber       = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A";
            model.Quantity           = containerPart.Quantity;
            model.Weight             = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.Cost              = foundryOrderPart.Cost;
            model.Price             = foundryOrderPart.Price;
            model.AvailableQuantity = (foundryOrderPart != null) ? foundryOrderPart.Quantity : 0;
            model.ShipCode          = (foundryOrderPart != null && !string.IsNullOrEmpty(foundryOrderPart.ShipCode)) ? foundryOrderPart.ShipCode : "N/A";

            if (_containerRepository != null)
            {
                _containerRepository.Dispose();
                _containerRepository = null;
            }

            if (_partRepository != null)
            {
                _partRepository.Dispose();
                _partRepository = null;
            }

            if (_dynamicsPartRepository != null)
            {
                _dynamicsPartRepository.Dispose();
                _dynamicsPartRepository = null;
            }

            if (_foundryOrderRepository != null)
            {
                _foundryOrderRepository.Dispose();
                _foundryOrderRepository = null;
            }

            return(model);
        }
Esempio n. 4
0
        /// <summary>
        /// convert containerPart view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ContainerPart ConvertToDomain(ContainerPartViewModel model)
        {
            ContainerPart containerPart = new ContainerPart();

            containerPart.ContainerPartId    = model.ContainerPartId;
            containerPart.FoundryOrderPartId = model.FoundryOrderPartId;
            containerPart.ContainerId        = model.ContainerId ?? Guid.Empty;
            containerPart.Quantity           = model.Quantity;
            containerPart.PalletNumber       = model.PalletNumber;

            return(containerPart);
        }
Esempio n. 5
0
        /// <summary>
        /// convert container part to packlingList part view model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public PackingListPartViewModel ConvertToView(ContainerPart containerPart)
        {
            PackingListPartViewModel model = new PackingListPartViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _customerOrderRepository = new CustomerOrderRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var part              = _partRepository.GetPart(foundryOrderPart.PartId);
            var dynamicsPart      = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : null);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart(foundryOrderPart.CustomerOrderPartId);
            var customerOrder     = _customerOrderRepository.GetCustomerOrder(customerOrderPart.CustomerOrderId);

            model.ShipCode       = foundryOrderPart.ShipCode;
            model.PartNumber     = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight     = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PartQuantity   = containerPart.Quantity;
            model.PalletNumber   = (!string.IsNullOrEmpty(containerPart.PalletNumber)) ? containerPart.PalletNumber : "N/A";
            model.PONumber       = (customerOrder != null && !string.IsNullOrEmpty(customerOrder.PONumber)) ? customerOrder.PONumber : "N/A";
            model.PalletQuantity = containerPart.Quantity;
            model.InvoiceNumber  = "Will fill in later";

            if (_foundryOrderRepository != null)
            {
                _foundryOrderRepository.Dispose();
                _foundryOrderRepository = null;
            }

            if (_partRepository != null)
            {
                _partRepository.Dispose();
                _partRepository = null;
            }

            if (_dynamicsPartRepository != null)
            {
                _dynamicsPartRepository.Dispose();
                _dynamicsPartRepository = null;
            }

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            return(model);
        }
Esempio n. 6
0
        /// <summary>
        /// get container part by id
        /// </summary>
        /// <param name="containerPartId"></param>
        /// <returns></returns>
        public ContainerPart GetContainerPart(Guid containerPartId)
        {
            var containerPart = new ContainerPart();

            try
            {
                containerPart = _db.ContainerPart.FirstOrDefault(x => x.ContainerPartId == containerPartId);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error getting container part: {0} ", ex.ToString());
            }

            return(containerPart);
        }
Esempio n. 7
0
 public void DoTaskElement(TaskElement element)
 {
     Debug.WriteLine("Current taskelement:");
     Debug.WriteLine("ID: " + element.Id + "\n Name:" + element.Name + "\n Description: " + element.Description);
     if (element.TypeId != null)
     {
         Models.Type type = typeController.GetTypeAsync(element.TypeId).Result;
         Debug.WriteLine("Required type: " + type.Name + "\n" + type.Description);
         Debug.WriteLine("+++++++++++++");
         List <ContainerPartContent> cpcList = containerPartContentController.GetContainerPartContentAsync(type.Id).Result;
         if (cpcList != null)
         {
             var           cpc           = cpcList.FirstOrDefault();
             ContainerPart containerPart = containerPartController.GetContainerPartAsync(cpc.ContainerPartId).Result;
             Debug.WriteLine("There is/are " + cpc.Amount + " in the " + containerPart.Name + " containerpart.");
         }
         else
         {
             throw new Exception("There isn't containerpart which contains the given type.");
         }
     }
 }
 private string GetListName(ContainerPart containerPart) {
     return _contentManager.GetItemMetadata(containerPart).DisplayText;
 }
 private string GetListName(ContainerPart containerPart)
 {
     return(_contentManager.GetItemMetadata(containerPart).DisplayText);
 }
Esempio n. 10
0
        /// <summary>
        /// convert container part to warehouse inventory list model
        /// </summary>
        /// <param name="containerPart"></param>
        /// <returns></returns>
        public WarehouseInventoryViewModel ConvertToListView(ContainerPart containerPart)
        {
            WarehouseInventoryViewModel model = new WarehouseInventoryViewModel();

            var _foundryOrderRepository  = new FoundryOrderRepository();
            var _customerOrderRepository = new CustomerOrderRepository();
            var _partRepository          = new PartRepository();
            var _dynamicsPartRepository  = new PartDynamicsRepository();
            var _containerRepository     = new ContainerRepository();

            var foundryOrderPart  = _foundryOrderRepository.GetFoundryOrderPart(containerPart.FoundryOrderPartId);
            var customerOrderPart = _customerOrderRepository.GetCustomerOrderPart((foundryOrderPart != null) ? foundryOrderPart.CustomerOrderPartId : Guid.Empty);
            var part         = _partRepository.GetPart((foundryOrderPart != null) ? foundryOrderPart.PartId : Guid.Empty);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((part != null) ? part.Number : string.Empty);
            var container    = _containerRepository.GetContainer(containerPart.ContainerId);

            model.CustomerId       = (part != null) ? part.CustomerId : "N/A";
            model.ShipCode         = (foundryOrderPart != null) ? foundryOrderPart.ShipCode : "N/A";
            model.PartNumber       = (part != null && !string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartWeight       = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.PalletNumber     = (!string.IsNullOrEmpty(part.Number)) ? containerPart.PalletNumber : "N/A";
            model.PalletQuantity   = containerPart.Quantity;
            model.TotalQuantity    = containerPart.Quantity;
            model.ContainerNumber  = (!string.IsNullOrEmpty(part.Number)) ? container.Number : "N/A";
            model.PONumber         = (customerOrderPart != null && !string.IsNullOrEmpty(customerOrderPart.CustomerOrder.PONumber)) ? customerOrderPart.CustomerOrder.PONumber : "N/A";
            model.WarehouseDate    = (foundryOrderPart != null) ? foundryOrderPart.ReceiptDate : DateTime.MinValue;
            model.WarehouseDateStr = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.ToShortDateString() : "N/A";
            model.SixtyDaysDate    = (foundryOrderPart != null && foundryOrderPart.ReceiptDate != null) ? foundryOrderPart.ReceiptDate.Value.AddDays(60) : DateTime.MinValue;
            model.SixtyDaysDateStr = (model.SixtyDaysDate != null) ? model.SixtyDaysDate.Value.ToShortDateString() : "N/A";

            if (_foundryOrderRepository != null)
            {
                _foundryOrderRepository.Dispose();
                _foundryOrderRepository = null;
            }

            if (_customerOrderRepository != null)
            {
                _customerOrderRepository.Dispose();
                _customerOrderRepository = null;
            }

            if (_partRepository != null)
            {
                _partRepository.Dispose();
                _partRepository = null;
            }

            if (_dynamicsPartRepository != null)
            {
                _dynamicsPartRepository.Dispose();
                _dynamicsPartRepository = null;
            }

            if (_containerRepository != null)
            {
                _containerRepository.Dispose();
                _containerRepository = null;
            }

            return(model);
        }