Exemple #1
0
        /// <summary>
        /// convert price sheet part to view model for quote price sheet
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PriceSheetPartViewModel ConvertToProjectPartView(PriceSheetPart part)
        {
            PriceSheetPartViewModel model = new PriceSheetPartViewModel();

            var _projectPartRepository = new ProjectPartRepository();
            var _priceSheetRepository  = new PriceSheetRepository();

            var priceSheet  = _priceSheetRepository.GetPriceSheet(part.PriceSheetId);
            var projectPart = _projectPartRepository.GetProjectPart(part.ProjectPartId);

            model.ProjectPartId         = part.ProjectPartId ?? Guid.Empty;
            model.PriceSheetPartId      = part.PriceSheetPartId;
            model.PriceSheetId          = part.PriceSheetId;
            model.PriceSheetNumber      = (priceSheet != null) ? priceSheet.Number : "N/A";
            model.PartNumber            = (projectPart != null) ? projectPart.Number : "N/A";
            model.PartDescription       = (projectPart != null) ? projectPart.Description : "N/A";
            model.AvailableQuantity     = part.AvailableQuantity;
            model.CustomerOrderQuantity = part.AvailableQuantity;
            model.UnitPrice             = part.Price;
            model.UnitCost = part.Cost;

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

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

            return(model);
        }
Exemple #2
0
        /// <summary>
        /// convert price sheet part to price sheet part price detail view model
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PriceSheetPriceDetailViewModel ConvertToPriceView(PriceSheetPart part)
        {
            PriceSheetPriceDetailViewModel model = new PriceSheetPriceDetailViewModel();

            var _projectPartRepository = new ProjectPartRepository();

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

            model.PriceSheetPartId = part.PriceSheetPartId;
            model.PartNumber       = (projectPart != null) ? projectPart.Number : "N/A";
            model.Weight           = (projectPart != null) ? projectPart.Weight : 0;
            model.AnnualUsage      = part.AnnualUsage;
            model.RawPrice         = part.RawPrice;
            model.AnnualRawPrice   = part.AnnualRawPrice;
            model.PNumber          = part.PNumberPrice;
            model.MachinePrice     = part.MachinePrice;
            model.FOBPrice         = part.FOBPrice;
            model.AddOn            = part.AddOnPrice;
            model.Surcharge        = part.SurchargePrice;
            model.Duty             = part.DutyCost;
            model.Price            = part.Price;
            model.AnnualPrice      = part.AnnualPrice;
            model.FixturePrice     = part.FixturePrice;
            model.PatternPrice     = part.PatternPrice;
            model.ProjectPartId    = part.ProjectPartId ?? Guid.Empty;

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

            return(model);
        }
Exemple #3
0
        /// <summary>
        /// save price sheet part
        /// </summary>
        /// <param name="newPriceSheetPart"></param>
        /// <returns></returns>
        public OperationResult SavePriceSheetPart(PriceSheetPart newPriceSheetPart)
        {
            var operationResult = new OperationResult();

            try
            {
                var priceSheetPart = _db.PriceSheetPart.FirstOrDefault(x => x.ProjectPartId == newPriceSheetPart.ProjectPartId && x.PriceSheetId == newPriceSheetPart.PriceSheetId);

                if (priceSheetPart == null)
                {
                    _db.PriceSheetPart.Add(newPriceSheetPart);

                    _db.SaveChanges();

                    operationResult.Success = true;
                    operationResult.Message = "Create Price Sheet success!";
                }
                else
                {
                    operationResult.Success = true;
                    operationResult.Message = "Duplicate Entry";
                }
            }
            catch (Exception ex)
            {
                operationResult.Message = "can not create this price sheet";
                operationResult.Success = false;
                logger.ErrorFormat("Error saving new price sheet: {0} ", ex.ToString());
            }

            return(operationResult);
        }
Exemple #4
0
        /// <summary>
        /// update price sheet part
        /// </summary>
        /// <param name="updatePriceSheetPart"></param>
        /// <returns></returns>
        public OperationResult UpdatePriceSheetPart(PriceSheetPart updatePriceSheetPart)
        {
            var operationResult = new OperationResult();

            var existingPriceSheetPart = _db.PriceSheetPart.Find(updatePriceSheetPart.PriceSheetPartId);

            if (existingPriceSheetPart != null)
            {
                try
                {
                    _db.Entry(existingPriceSheetPart).CurrentValues.SetValues(updatePriceSheetPart);

                    _db.SaveChanges();

                    operationResult.Success = true;
                    operationResult.Message = "Update Price Sheet Part success!";
                }
                catch (Exception ex)
                {
                    operationResult.Message = "can not update this price sheet part";
                    operationResult.Success = false;
                    logger.ErrorFormat("Error while updating price sheet part: { 0} ", ex.ToString());
                }
            }
            else
            {
                operationResult.Success = false;
                operationResult.Message = "Unable to find selected priceSheetPart.";
            }

            return(operationResult);
        }
Exemple #5
0
        /// <summary>
        /// get production price sheet part by project part
        /// </summary>
        /// <param name="projectPartId"></param>
        /// <returns></returns>
        public PriceSheetPart GetProductionPriceSheetPartByProjectPart(Guid projectPartId)
        {
            var part = new PriceSheetPart();

            try
            {
                part = _db.PriceSheetPart.FirstOrDefault(x => x.ProjectPartId == projectPartId && x.IsProduction);
            }
            catch (Exception ex)
            {
                logger.ErrorFormat("Error getting price sheet part: {0} ", ex.ToString());
            }

            return(part);
        }
Exemple #6
0
        /// <summary>
        /// convert price sheet part to view model for production price sheet
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public PriceSheetPartViewModel ConvertToPartView(PriceSheetPart part)
        {
            PriceSheetPartViewModel model = new PriceSheetPartViewModel();

            var _partRepository         = new PartRepository();
            var _dynamicsPartRepository = new PartDynamicsRepository();
            var _priceSheetRepository   = new PriceSheetRepository();
            var _projectPartRepository  = new ProjectPartRepository();

            var priceSheet   = _priceSheetRepository.GetPriceSheet(part.PriceSheetId);
            var projectPart  = _projectPartRepository.GetProjectPart(part.ProjectPartId);
            var tempPart     = _partRepository.GetPart((projectPart != null) ? projectPart.PartId : null);
            var dynamicsPart = _dynamicsPartRepository.GetPartMaster((tempPart != null) ? tempPart.Number : null);

            model.ProjectPartId         = part.ProjectPartId ?? Guid.Empty;
            model.PartId                = (tempPart != null) ? tempPart.PartId : Guid.Empty;
            model.PriceSheetPartId      = part.PriceSheetPartId;
            model.PriceSheetId          = part.PriceSheetId;
            model.PriceSheetNumber      = (priceSheet != null) ? priceSheet.Number : "N/A";
            model.PartNumber            = (tempPart != null) ? tempPart.Number : "N/A";
            model.PartDescription       = (dynamicsPart != null && !string.IsNullOrEmpty(dynamicsPart.ITEMDESC)) ? dynamicsPart.ITEMDESC : "N/A";
            model.AvailableQuantity     = part.AvailableQuantity;
            model.CustomerOrderQuantity = part.AvailableQuantity;
            model.UnitPrice             = part.Price;
            model.UnitCost              = part.Cost;

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

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

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

            return(model);
        }
Exemple #7
0
        /// <summary>
        /// convert project part to price sheet part
        /// </summary>
        /// <param name="projectPart"></param>
        /// <returns></returns>
        public PriceSheetPart ConvertToDomain(ProjectPart projectPart)
        {
            PriceSheetPart priceSheetPart = new PriceSheetPart();

            priceSheetPart.PriceSheetId  = projectPart.PriceSheetId ?? Guid.Empty;
            priceSheetPart.ProjectPartId = projectPart.ProjectPartId;
            priceSheetPart.PartId        = null;
            priceSheetPart.Cost          = projectPart.Cost;
            priceSheetPart.Price         = projectPart.Price;
            priceSheetPart.AnnualUsage   = projectPart.AnnualUsage;
            priceSheetPart.PatternCost   = projectPart.PatternCost;
            priceSheetPart.PatternPrice  = projectPart.PatternPrice;
            priceSheetPart.FixturePrice  = projectPart.FixturePrice;
            priceSheetPart.FixtureCost   = projectPart.FixtureCost;

            return(priceSheetPart);
        }
Exemple #8
0
        /// <summary>
        /// convert price sheet view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public PriceSheet ConvertToDomain(PriceSheetViewModel model)
        {
            var _rfqRepository = new RfqRepository();

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

            var priceSheet = new PriceSheet();

            priceSheet.PriceSheetId        = model.PriceSheetId;
            priceSheet.Number              = model.Number;
            priceSheet.WAF                 = model.WAF;
            priceSheet.ProjectMargin       = model.ProjectMargin;
            priceSheet.AnnualDollars       = model.AnnualDollars;
            priceSheet.AnnualMargin        = model.AnnualMargin;
            priceSheet.AnnualWeight        = model.AnnualWeight;
            priceSheet.AnnualContainer     = model.AnnualContainer;
            priceSheet.DollarContainer     = model.DollarContainer;
            priceSheet.InsuranceFreight    = model.InsuranceFreight;
            priceSheet.InsurancePercentage = model.InsurancePercentage;
            priceSheet.InsuranceDuty       = model.InsuranceDuty;
            priceSheet.InsuranceDivisor    = model.InsuranceDivisor;
            priceSheet.InsurancePremium    = model.InsurancePremium;
            priceSheet.ToolingMargin       = model.ToolingMargin;
            priceSheet.FixtureMargin       = model.FixtureMargin;
            priceSheet.IsQuote             = model.IsQuote;
            priceSheet.IsProduction        = model.IsProduction;
            priceSheet.RfqId               = model.RfqId;
            priceSheet.ProjectId           = (rfq != null) ? rfq.ProjectId : (Guid?)null;
            priceSheet.PriceSheetBuckets   = model.BucketList;

            if (model.CostDetailList != null && model.CostDetailList.Count > 0)
            {
                priceSheet.PriceSheetParts = new List <PriceSheetPart>();

                foreach (var costDetail in model.CostDetailList)
                {
                    var priceSheetPart = new PriceSheetPart();

                    priceSheetPart.PriceSheetPartId  = costDetail.PriceSheetPartId;
                    priceSheetPart.PriceSheetId      = model.PriceSheetId;
                    priceSheetPart.AddOnCost         = costDetail.AddOn;
                    priceSheetPart.AnnualCost        = costDetail.AnnualCost;
                    priceSheetPart.AnnualRawCost     = costDetail.AnnualRawCost;
                    priceSheetPart.AnnualUsage       = costDetail.AnnualUsage;
                    priceSheetPart.AvailableQuantity = (int)costDetail.AnnualUsage;
                    priceSheetPart.Cost          = costDetail.Cost;
                    priceSheetPart.DutyCost      = costDetail.Duty;
                    priceSheetPart.FixtureCost   = costDetail.FixtureCost;
                    priceSheetPart.FOBCost       = costDetail.FOBCost;
                    priceSheetPart.MachineCost   = costDetail.MachineCost;
                    priceSheetPart.PatternCost   = costDetail.PatternCost;
                    priceSheetPart.PNumberCost   = costDetail.PNumber;
                    priceSheetPart.ProjectPartId = costDetail.ProjectPartId;
                    priceSheetPart.PartId        = null;
                    priceSheetPart.RawCost       = costDetail.RawCost;
                    priceSheetPart.SurchargeCost = costDetail.Surcharge;
                    priceSheetPart.IsQuote       = model.IsQuote;
                    priceSheetPart.IsProduction  = model.IsProduction;

                    var priceDetail = model.PriceDetailList.FirstOrDefault(x => x.ProjectPartId == costDetail.ProjectPartId);
                    if (priceDetail != null)
                    {
                        priceSheetPart.AddOnPrice     = priceDetail.AddOn;
                        priceSheetPart.AnnualPrice    = priceDetail.AnnualPrice;
                        priceSheetPart.AnnualRawPrice = priceDetail.AnnualRawPrice;
                        priceSheetPart.DutyPrice      = priceDetail.Duty;
                        priceSheetPart.FixturePrice   = priceDetail.FixturePrice;
                        priceSheetPart.FOBPrice       = priceDetail.FOBPrice;
                        priceSheetPart.MachinePrice   = priceDetail.MachinePrice;
                        priceSheetPart.PatternPrice   = priceDetail.PatternPrice;
                        priceSheetPart.PNumberPrice   = priceDetail.PNumber;
                        priceSheetPart.Price          = priceDetail.Price;
                        priceSheetPart.RawPrice       = priceDetail.RawPrice;
                        priceSheetPart.SurchargePrice = priceDetail.Surcharge;
                    }

                    priceSheet.PriceSheetParts.Add(priceSheetPart);
                }
            }

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

            return(priceSheet);
        }