Exemplo n.º 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));
        }
Exemplo n.º 2
0
        public JsonResult Create(PriceSheetViewModel priceSheet)
        {
            var operationResult = new OperationResult();

            var rfq = _rfqRepository.GetRfq(priceSheet.RfqId);

            var newPriceSheet = new PriceSheetConverter().ConvertToDomain(priceSheet);

            operationResult = _priceSheetRepository.SavePriceSheet(newPriceSheet);

            if (operationResult.Success && priceSheet.IsQuote)
            {
                rfq.IsOpen      = false;
                operationResult = _rfqRepository.UpdateRfq(rfq);
            }

            var insertedPriceSheet = _priceSheetRepository.GetPriceSheet(priceSheet.Number);

            if (operationResult.Success)
            {
                if (priceSheet.CostDetailList != null && priceSheet.CostDetailList.Count > 0)
                {
                    foreach (var costDetail in priceSheet.CostDetailList)
                    {
                        var priceDetail = priceSheet.PriceDetailList.FirstOrDefault(x => x.ProjectPartId == costDetail.ProjectPartId);

                        var tempPart = _projectPartRepository.GetProjectPart(costDetail.ProjectPartId);
                        {
                            tempPart.Weight       = costDetail.Weight;
                            tempPart.AnnualUsage  = (int)costDetail.AnnualUsage;
                            tempPart.Cost         = costDetail.Cost;
                            tempPart.PatternCost  = costDetail.PatternCost;
                            tempPart.FixtureCost  = costDetail.FixtureCost;
                            tempPart.PriceSheetId = insertedPriceSheet.PriceSheetId;
                            tempPart.Price        = priceDetail.Price;
                            tempPart.PatternPrice = priceDetail.PatternPrice;
                            tempPart.FixturePrice = priceDetail.FixturePrice;
                        }
                        operationResult = _projectPartRepository.UpdateProjectPart(tempPart);
                    }
                }

                if (operationResult.Success && priceSheet.IsQuote)
                {
                    operationResult = _rfqRepository.UpdatePriceSheet(rfq.RfqId, priceSheet.Number);
                }
                else if (priceSheet.IsProduction && operationResult.Success)
                {
                    if (priceSheet.QuoteId != Guid.Empty)
                    {
                        var quote = _quoteRepository.GetQuote(priceSheet.QuoteId);
                        quote.IsOpen    = false;
                        operationResult = _quoteRepository.UpdateQuote(quote);
                    }

                    ConvertProjectPartsToParts(insertedPriceSheet.PriceSheetId);
                }
            }

            operationResult.ReferenceId = insertedPriceSheet.PriceSheetId;

            return(Json(operationResult, JsonRequestBehavior.AllowGet));;
        }
Exemplo n.º 3
0
        public JsonResult Create(QuoteViewModel model)
        {
            var operationResult = new OperationResult();

            Quote newQuote = new QuoteConverter().ConvertToDomain(model);

            operationResult = _quoteRepository.SaveQuote(newQuote);

            if (operationResult.Success)
            {
                var quoteId = operationResult.ReferenceId;

                var rfq = _rfqRepository.GetRfq(model.RfqId);

                if (rfq != null)
                {
                    rfq.IsOpen      = false;
                    operationResult = _rfqRepository.UpdateRfq(rfq);
                }

                var rfqId             = model.RfqId;
                var priceSheetId      = model.PriceSheetId;
                var projectId         = model.ProjectId;
                var customerAddressId = model.CustomerAddressId;
                var foundryId         = (rfq != null) ? rfq.FoundryId : string.Empty;
                var htsNumberId       = model.HtsNumberId;
                var shipmentTermId    = model.ShipmentTermId;
                var paymentTermId     = model.PaymentTermId;
                var materialId        = model.MaterialId;
                var coatingTypeId     = model.CoatingTypeId;

                var quotePriceSheet = _priceSheetRepository.GetPriceSheet(priceSheetId ?? Guid.Empty);

                if (model.QuoteParts != null && model.QuoteParts.Count() > 0)
                {
                    foreach (var quotePart in model.QuoteParts)
                    {
                        var projectPart = new ProjectPartConverter().ConvertToDomain(quotePart);

                        projectPart.RfqId             = rfqId;
                        projectPart.PriceSheetId      = priceSheetId;
                        projectPart.QuoteId           = quoteId;
                        projectPart.ProjectId         = projectId;
                        projectPart.CustomerAddressId = customerAddressId;
                        projectPart.FoundryId         = (!string.IsNullOrEmpty(foundryId)) ? foundryId : projectPart.FoundryId;
                        projectPart.HtsNumberId       = htsNumberId;
                        projectPart.ShipmentTermId    = shipmentTermId;
                        projectPart.PaymentTermId     = paymentTermId;
                        projectPart.MaterialId        = materialId;
                        projectPart.CoatingTypeId     = coatingTypeId;
                        projectPart.FixtureDate       = (quotePriceSheet != null) ? quotePriceSheet.CreatedDate : null; //enter from price sheet
                        projectPart.PatternDate       = (quotePriceSheet != null) ? quotePriceSheet.CreatedDate : null; //enter from price sheet

                        var projectPartToUpdate = _projectPartRepository.GetProjectPart(projectPart.ProjectPartId);

                        if (projectPartToUpdate != null)
                        {
                            operationResult = _projectPartRepository.UpdateProjectPart(projectPart);
                        }
                        else
                        {
                            operationResult           = _projectPartRepository.SaveProjectPart(projectPart);
                            projectPart.ProjectPartId = operationResult.ReferenceId;

                            if (quotePriceSheet != null)
                            {
                                var newPriceSheetPart = new PriceSheetPartConverter().ConvertToDomain(projectPart);

                                newPriceSheetPart.IsQuote      = true;
                                newPriceSheetPart.IsProduction = false;
                                operationResult = _priceSheetRepository.SavePriceSheetPart(newPriceSheetPart);
                            }
                        }
                    }
                }

                operationResult.ReferenceId = quoteId;
            }



            return(Json(operationResult, JsonRequestBehavior.AllowGet));
        }