예제 #1
0
        public ActionResult Detail(Guid partId)
        {
            var model = new PartViewModel();

            var currentPart = _projectPartRepository.GetProjectPart(partId);

            if (currentPart != null)
            {
                var projectPart = _projectPartRepository.GetProjectPart(partId);

                model = new ProjectPartConverter().ConvertToView(projectPart);
            }
            else
            {
                var part = _partRepository.GetPart(partId);

                model = new PartConverter().ConvertToView(part);
            }

            model.SelectableCustomers = _customerDynamicsRepository.GetSelectableCustomers();

            var defaultCustomer = new SelectListItem()
            {
                Text  = "--Select Customer--",
                Value = null
            };

            model.SelectableCustomers.Insert(0, defaultCustomer);

            model.SelectableFoundries = _foundryDynamicsRepository.GetSelectableFoundries();

            var defaultFoundry = new SelectListItem()
            {
                Text  = "--Select Foundry--",
                Value = null
            };

            model.SelectableFoundries.Insert(0, defaultFoundry);

            var htsNumbers = _htsNumberRepository.GetSelectableHtsNumbers();

            var defaultHtsNumber = new SelectListItem()
            {
                Text  = "--Select Hts Number--",
                Value = null
            };

            htsNumbers.Insert(0, defaultHtsNumber);

            model.SelectableHtsNumbers = htsNumbers;

            var material = _materialRepository.GetSelectableMaterials();

            var defaultMaterial = new SelectListItem()
            {
                Text  = "--Select Material--",
                Value = null
            };

            material.Insert(0, defaultMaterial);

            model.SelectableMaterial = material;

            var specificationMaterial = _specificationMaterialRepository.GetSelectableSpecificationMaterials();

            var defaultSpecification = new SelectListItem()
            {
                Text  = "--Select Material Specification--",
                Value = null
            };

            specificationMaterial.Insert(0, defaultSpecification);

            model.SelectableSpecificationMaterial = specificationMaterial;

            var partStates = _partStatusRepository.GetSelectablePartStates();

            var defaultPartStatus = new SelectListItem()
            {
                Text  = "--Select Part Status--",
                Value = null
            };

            partStates.Insert(0, defaultPartStatus);

            model.SelectablePartStates = partStates;

            var destinations = _destinationRepository.GetSelectableDestinations();

            var defaultDestination = new SelectListItem()
            {
                Text  = "--Select Destination--",
                Value = null
            };

            destinations.Insert(0, defaultDestination);

            model.SelectableDestinations = destinations;

            var partTypes = _partTypeRepository.GetSelectablePartTypes();

            var defaultPartType = new SelectListItem()
            {
                Text  = "--Select Part Type--",
                Value = null
            };

            partTypes.Insert(0, defaultPartType);

            model.SelectablePartTypes = partTypes;

            model.SelectableProjects = _projectRepository.GetSelectablePartProjects(partId);

            var paymentTerms = _paymentTermRepository.GetSelectablePaymentTerms();

            var defaultPaymentTerm = new SelectListItem()
            {
                Text  = "--Select Payment Term--",
                Value = null
            };

            paymentTerms.Insert(0, defaultPaymentTerm);

            model.SelectablePaymentTerms = paymentTerms;

            var shipmentTerms = _shipmentTermRepository.GetSelectableShipmentTerms();

            var defaultShipmentTerm = new SelectListItem()
            {
                Text  = "--Select Shipment Term--",
                Value = null
            };

            shipmentTerms.Insert(0, defaultShipmentTerm);

            model.SelectableShipmentTerms = shipmentTerms;

            var surcharge = _surchargeRepository.GetSelectableSurcharges();

            model.SelectableSurcharge = surcharge;

            var defaultSurcharge = new SelectListItem()
            {
                Text  = "--Select Surcharge--",
                Value = null
            };

            surcharge.Insert(0, defaultSurcharge);

            model.SelectableSites = _siteDynamicsRepository.GetSelectableSites();

            var defaultSite = new SelectListItem()
            {
                Text  = "--Select Site--",
                Value = null
            };

            model.SelectableSites.Insert(0, defaultSite);

            var coatingTypes = _coatingTypeRepository.GetSelectableCoatingTypes();

            var defaultCoatingType = new SelectListItem()
            {
                Text  = "--Select Coating Type--",
                Value = null
            };

            coatingTypes.Insert(0, defaultCoatingType);

            model.SelectableCoatingTypes = coatingTypes;

            var patternMaterial = _patternMaterialRepository.GetSelectablePatternMaterials();

            var defaultPattern = new SelectListItem()
            {
                Text  = "--Select Pattern Material--",
                Value = null
            };

            patternMaterial.Insert(0, defaultPattern);

            model.SelectablePatternMaterial = patternMaterial;

            return(View(model));
        }