コード例 #1
0
        /// <summary>
        /// convert project part to rfq part view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public RfqPartViewModel ConvertToView(ProjectPart part)
        {
            RfqPartViewModel model = new RfqPartViewModel();

            var _materialRepository = new MaterialRepository();

            var material = _materialRepository.GetMaterial(part.MaterialId);

            model.ProjectPartId       = part.ProjectPartId;
            model.PartId              = part.PartId;
            model.PartNumber          = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.RevisionNumber      = (!string.IsNullOrEmpty(part.RevisionNumber)) ? part.RevisionNumber : "N/A";
            model.PartDescription     = (!string.IsNullOrEmpty(part.Description)) ? part.Description : "N/A";
            model.CustomerId          = part.CustomerId;
            model.FoundryId           = part.FoundryId;
            model.IsRaw               = part.IsRaw;
            model.IsMachined          = part.IsMachined;
            model.Weight              = part.Weight;
            model.AnnualUsage         = part.AnnualUsage;
            model.MaterialId          = part.MaterialId;
            model.MaterialDescription = (material != null && !string.IsNullOrEmpty(material.Description)) ? material.Description : "N/A";
            model.PartTypeId          = part.PartTypeId;
            model.PartStatusId        = part.PartStatusId;
            model.DestinationId       = part.DestinationId;
            model.SurchargeId         = part.SurchargeId;

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

            return(model);
        }
コード例 #2
0
        /// <summary>
        /// convert part to rfq part view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public RfqPartViewModel ConvertToView(Part part)
        {
            RfqPartViewModel model = new RfqPartViewModel();

            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _materialRepository     = new MaterialRepository();

            var dynamicsPart = _dynamicsPartRepository.GetPartMaster(part.Number);
            var material     = _materialRepository.GetMaterial(part.MaterialId);
            var partDrawing  = _partRepository.GetPartDrawings(part.PartId).FirstOrDefault(x => x.IsLatest);

            model.PartId              = part.PartId;
            model.PartNumber          = (!string.IsNullOrEmpty(part.Number)) ? part.Number : "N/A";
            model.PartDescription     = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.CustomerId          = part.CustomerId;
            model.FoundryId           = part.FoundryId;
            model.Weight              = (dynamicsPart != null) ? (dynamicsPart.ITEMSHWT / 100.00m) : 0.00m;
            model.AnnualUsage         = part.AnnualUsage;
            model.IsMachined          = part.IsMachined;
            model.MaterialId          = part.MaterialId;
            model.MaterialDescription = (material != null && !string.IsNullOrEmpty(material.Description)) ? material.Description : "N/A";
            model.RevisionNumber      = (partDrawing != null && !string.IsNullOrEmpty(partDrawing.RevisionNumber)) ? partDrawing.RevisionNumber : "N/A";
            model.PartDrawingId       = (partDrawing != null) ? partDrawing.PartDrawingId : Guid.Empty;
            model.PartTypeId          = part.PartTypeId;
            model.PartStatusId        = part.PartStatusId;
            model.DestinationId       = part.DestinationId;
            model.SurchargeId         = part.SurchargeId;
            model.SubFoundryId        = part.SubFoundryId;

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

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

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

            return(model);
        }
コード例 #3
0
        /// <summary>
        /// convert rfq part view model to project part
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ProjectPart ConvertToDomain(RfqPartViewModel model)
        {
            ProjectPart projectPart = new ProjectPart();

            var _partRepository        = new PartRepository();
            var _projectPartRepository = new ProjectPartRepository();
            var _partStatusRepository  = new PartStatusRepository();

            var active = _partStatusRepository.GetPartStates().FirstOrDefault(x => x.Description == "Active");

            projectPart.ProjectPartId     = model.ProjectPartId;
            projectPart.PartId            = model.PartId;
            projectPart.Number            = model.PartNumber;
            projectPart.AccountCode       = null;
            projectPart.Description       = model.PartDescription;
            projectPart.RevisionNumber    = model.RevisionNumber;
            projectPart.PriceSheetId      = null;
            projectPart.QuoteId           = null;
            projectPart.CustomerId        = model.CustomerId;
            projectPart.CustomerAddressId = null;
            projectPart.FoundryId         = model.FoundryId;
            projectPart.SubFoundryId      = (model.IsNew) ? model.FoundryId : model.SubFoundryId;
            projectPart.HtsNumberId       = null;
            projectPart.MaterialId        = model.MaterialId;
            projectPart.PartStatusId      = (model.IsNew) ? (active != null) ? active.PartStatusId : Guid.Empty : model.PartStatusId;
            projectPart.PartTypeId        = (model.IsNew) ? null : model.PartTypeId;
            projectPart.ShipmentTermId    = null;
            projectPart.PaymentTermId     = null;
            projectPart.SurchargeId       = (model.IsNew) ? null : model.SurchargeId;
            projectPart.SiteId            = null;
            projectPart.DestinationId     = (model.IsNew) ? null : model.DestinationId;
            projectPart.PatternMaterialId = null;
            projectPart.IsRaw             = model.IsRaw;
            projectPart.IsMachined        = model.IsMachined;
            projectPart.Weight            = model.Weight;
            projectPart.Cost               = 0.00m;
            projectPart.Price              = 0.00m;
            projectPart.PalletQuantity     = 0;
            projectPart.AdditionalCost     = 0.00m;
            projectPart.AnnualUsage        = model.AnnualUsage;
            projectPart.FixtureDate        = null;
            projectPart.FixtureCost        = 0.00m;
            projectPart.FixturePrice       = 0.00m;
            projectPart.PatternDate        = null;
            projectPart.PatternCost        = 0.00m;
            projectPart.PatternPrice       = 0.00m;
            projectPart.IsFamilyPattern    = false;
            projectPart.Notes              = null;
            projectPart.CustomerOrderId    = null;
            projectPart.FoundryOrderId     = null;
            projectPart.ToolingDescription = null;

            if (!string.IsNullOrEmpty(model.RevisionNumber) && model.RevisionNumber != "N/A")
            {
                projectPart.ProjectPartDrawings = new List <ProjectPartDrawing>();

                ProjectPartDrawing projectPartDrawing = new ProjectPartDrawing();

                if (model.Drawing != null)
                {
                    projectPartDrawing.ProjectPartId  = model.ProjectPartId;
                    projectPartDrawing.RevisionNumber = model.Drawing.RevisionNumber;
                    projectPartDrawing.Type           = model.Drawing.Type;
                    projectPartDrawing.Length         = model.Drawing.Length;
                    projectPartDrawing.Content        = model.Drawing.Content;
                    projectPartDrawing.IsLatest       = model.Drawing.IsLatest;
                    projectPartDrawing.IsMachined     = model.Drawing.IsMachined;
                    projectPartDrawing.IsRaw          = model.Drawing.IsRaw;
                    projectPartDrawing.IsActive       = model.Drawing.IsActive;
                }
                else
                {
                    if (model.PartId != null)
                    {
                        var drawing = _partRepository.GetPartDrawings(model.PartId ?? Guid.Empty).FirstOrDefault(x => x.RevisionNumber == model.RevisionNumber);
                        projectPartDrawing.ProjectPartId = model.ProjectPartId;
                        if (drawing != null)
                        {
                            projectPartDrawing.RevisionNumber = drawing.RevisionNumber;
                            projectPartDrawing.Type           = drawing.Type;
                            projectPartDrawing.Length         = drawing.Length;
                            projectPartDrawing.Content        = drawing.Content;
                            projectPartDrawing.IsLatest       = drawing.IsLatest;
                            projectPartDrawing.IsMachined     = drawing.IsMachined;
                            projectPartDrawing.IsRaw          = drawing.IsRaw;
                        }
                        projectPartDrawing.IsActive = true;
                    }
                    else
                    {
                        var drawing = _projectPartRepository.GetProjectPartDrawings(model.ProjectPartId).FirstOrDefault(x => x.RevisionNumber == model.RevisionNumber);
                        projectPartDrawing.ProjectPartId  = model.ProjectPartId;
                        projectPartDrawing.RevisionNumber = drawing.RevisionNumber;
                        projectPartDrawing.Type           = drawing.Type;
                        projectPartDrawing.Length         = drawing.Length;
                        projectPartDrawing.Content        = drawing.Content;
                        projectPartDrawing.IsLatest       = drawing.IsLatest;
                        projectPartDrawing.IsMachined     = drawing.IsMachined;
                        projectPartDrawing.IsRaw          = drawing.IsRaw;
                        projectPartDrawing.IsActive       = true;
                    }
                }

                projectPart.ProjectPartDrawings.Add(projectPartDrawing);
            }

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

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

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

            return(projectPart);
        }