Exemple #1
0
        /// <summary>
        /// convert rfq to list model
        /// </summary>
        /// <param name="rfq"></param>
        /// <returns></returns>
        public RfqViewModel ConvertToListView(Rfq rfq)
        {
            RfqViewModel model = new RfqViewModel();

            var _projectRepository = new ProjectRepository();

            var project = _projectRepository.GetProject(rfq.ProjectId);

            model.RfqId              = rfq.RfqId;
            model.ProjectName        = (project != null && !string.IsNullOrEmpty(project.Name)) ? project.Name : "N/A";
            model.RfqNumber          = (!string.IsNullOrEmpty(rfq.Number)) ? rfq.Number : "N/A";
            model.RfqDate            = rfq.RfqDate;
            model.HoldNotes          = rfq.HoldNotes;
            model.HoldExpirationDate = rfq.HoldExpirationDate;
            model.RfqDateStr         = rfq.RfqDate.ToShortDateString();
            model.IsOpen             = rfq.IsOpen;
            model.IsHold             = rfq.IsHold;
            model.IsCanceled         = rfq.IsCanceled;
            model.Status             = rfq.IsOpen ? "Open" : rfq.IsCanceled ? "Canceled" : rfq.IsHold ? "On Hold" : "N/A";
            model.CreatedDate        = rfq.CreatedDate;

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

            return(model);
        }
Exemple #2
0
        public ActionResult _EditRfqPart()
        {
            var model = new RfqViewModel();

            model.SelectableMaterial = _materialRepository.GetSelectableMaterials();

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

            model.SelectableMaterial.Insert(0, defaultMaterial);

            return(PartialView(model));
        }
Exemple #3
0
        public ActionResult Index()
        {
            var model = new RfqViewModel();

            var rfqs = _rfqRepository.GetRfqs().Where(x => x.IsOpen).ToList();

            if (rfqs != null && rfqs.Count > 0)
            {
                model.Rfqs = new List <RfqViewModel>();
                foreach (var rfq in rfqs)
                {
                    RfqViewModel convertedModel = new RfqConverter().ConvertToListView(rfq);
                    model.Rfqs.Add(convertedModel);
                }
            }

            return(View(model));
        }
Exemple #4
0
        public JsonResult GetCanceledRfqs()
        {
            var model = new RfqViewModel();

            var tempRfqs = _rfqRepository.GetRfqs().Where(x => x.IsCanceled).ToList();

            if (tempRfqs != null && tempRfqs.Count > 0)
            {
                model.Rfqs = new List <RfqViewModel>();
                foreach (var tempRfq in tempRfqs)
                {
                    RfqViewModel convertedModel = new RfqConverter().ConvertToListView(tempRfq);
                    model.Rfqs.Add(convertedModel);
                }
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #5
0
        /// <summary>
        /// convert rfq view model to project for create project
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Project ConvertToCreate(RfqViewModel model)
        {
            var project = new Project();

            project.ProjectId          = model.ProjectId;
            project.CustomerId         = model.CustomerId;
            project.FoundryId          = model.FoundryId;
            project.Name               = model.ProjectName;
            project.IsOpen             = true;
            project.IsHold             = false;
            project.HoldExpirationDate = null;
            project.HoldNotes          = null;
            project.IsCanceled         = false;
            project.CancelNotes        = null;
            project.CanceledDate       = null;
            project.IsComplete         = false;
            project.CompletedDate      = null;

            return(project);
        }
Exemple #6
0
        public ActionResult Edit(Guid rfqId)
        {
            RfqViewModel model = new RfqViewModel();

            var currentRfq = _rfqRepository.GetRfq(rfqId);

            model = new RfqConverter().ConvertToView(currentRfq);

            model.Parts = _partRepository.GetSelectablePartsByCustomer(currentRfq.CustomerId);

            model.SelectableShipmentTerms = _shipmentTermRepository.GetSelectableShipmentTerms();

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

            model.SelectableShipmentTerms.Insert(0, defaultShipmentTerm);

            model.SelectableCoatingTypes = _coatingTypeRepository.GetSelectableCoatingTypes();

            model.SelectableSpecificationMaterial = _specificationMaterialRepository.GetSelectableSpecificationMaterials();

            model.SelectableMaterial = _materialRepository.GetSelectableMaterials();

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

            model.SelectableMaterial.Insert(0, defaultMaterial);

            model.MaterialId = (model.RfqParts != null) ? model.RfqParts[0].MaterialId : null;

            model.CurrentUser = User.Identity.Name;

            return(View(model));
        }
Exemple #7
0
        public JsonResult Edit(RfqViewModel model)
        {
            var operationResult     = new OperationResult();
            var existingCoatingType = _coatingTypeRepository.GetCoatingType(model.CoatingType);

            if (existingCoatingType == null)
            {
                var newCoatingType = new CoatingType();
                {
                    newCoatingType.Description = model.CoatingType;
                    newCoatingType.IsActive    = true;
                }
                operationResult     = _coatingTypeRepository.SaveCoatingType(newCoatingType);
                existingCoatingType = _coatingTypeRepository.GetCoatingType(model.CoatingType);
            }

            var existingSpecificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial(model.SpecificationMaterialDescription.ToLower().Replace(" ", string.Empty));

            if (existingSpecificationMaterial == null)
            {
                var newSpecificationMaterial = new SpecificationMaterial();
                {
                    newSpecificationMaterial.Description = model.SpecificationMaterialDescription;
                    newSpecificationMaterial.IsActive    = true;
                }
                operationResult = _specificationMaterialRepository.SaveSpecificationMaterial(newSpecificationMaterial);
                existingSpecificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial(model.SpecificationMaterialDescription);
            }

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

            rfqToUpdate = new RfqConverter().ConvertToDomain(model);

            var projectToUpdate = _projectRepository.GetProject(model.ProjectId);

            if (model.Status != null)
            {
                if (model.IsOpen)
                {
                    projectToUpdate.IsOpen = true;
                }
                else
                {
                    projectToUpdate.IsOpen = false;
                }

                if (model.IsHold)
                {
                    projectToUpdate.IsHold             = true;
                    projectToUpdate.HoldExpirationDate = model.HoldExpirationDate;
                    projectToUpdate.HoldNotes          = model.HoldNotes;
                }
                else
                {
                    projectToUpdate.IsHold             = false;
                    projectToUpdate.HoldExpirationDate = null;
                    projectToUpdate.HoldNotes          = null;
                }

                if (model.IsCanceled)
                {
                    projectToUpdate.IsCanceled  = true;
                    projectToUpdate.CancelNotes = model.CancelNotes;
                }
                else
                {
                    projectToUpdate.IsCanceled  = false;
                    projectToUpdate.CancelNotes = null;
                }
            }

            operationResult = _rfqRepository.UpdateRfq(rfqToUpdate);

            if (operationResult.Success)
            {
                model.Success    = true;
                model.IsHold     = rfqToUpdate.IsHold;
                model.IsCanceled = rfqToUpdate.IsCanceled;

                operationResult = _projectRepository.UpdateProject(projectToUpdate);

                if (model.RfqParts != null && model.RfqParts.Count() > 0)
                {
                    foreach (var rfqPart in model.RfqParts)
                    {
                        if (rfqPart.ProjectPartId != Guid.Empty)
                        {
                            var partToUpdate = new ProjectPartConverter().ConvertToDomain(rfqPart);
                            partToUpdate.RfqId     = model.RfqId;
                            partToUpdate.ProjectId = model.ProjectId;
                            partToUpdate.MaterialSpecificationId = existingSpecificationMaterial.SpecificationMaterialId;
                            partToUpdate.MaterialId    = rfqPart.MaterialId;
                            partToUpdate.CoatingTypeId = existingCoatingType.CoatingTypeId;
                            operationResult            = _projectPartRepository.UpdateProjectPart(partToUpdate);
                        }
                        else
                        {
                            var newProjectPart = new ProjectPartConverter().ConvertToDomain(rfqPart);

                            newProjectPart.RfqId      = model.RfqId;
                            newProjectPart.ProjectId  = model.ProjectId;
                            newProjectPart.MaterialId = rfqPart.MaterialId;
                            newProjectPart.MaterialSpecificationId = existingSpecificationMaterial.SpecificationMaterialId;
                            newProjectPart.CoatingTypeId           = existingCoatingType.CoatingTypeId;

                            operationResult = _projectPartRepository.SaveProjectPart(newProjectPart);
                        }
                    }
                }

                var existingProjectParts = _projectPartRepository.GetProjectParts().Where(x => x.ProjectId == model.ProjectId).ToList();

                if (existingProjectParts != null && existingProjectParts.Count > 0)
                {
                    foreach (var existingProjectPart in existingProjectParts)
                    {
                        var projectPart = model.RfqParts.FirstOrDefault(x => x.PartNumber == existingProjectPart.Number);

                        if (projectPart == null)
                        {
                            operationResult = _projectPartRepository.DeleteProjectPart(existingProjectPart.ProjectPartId);
                        }
                    }
                }

                if (!operationResult.Success)
                {
                    model.Success = false;
                    model.Message = operationResult.Message;
                }
            }
            else
            {
                model.Success = false;
                model.Message = operationResult.Message;
            }


            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemple #8
0
        public JsonResult Create(RfqViewModel model)
        {
            var operationResult = new OperationResult();

            var existingCoatingType = _coatingTypeRepository.GetCoatingType(model.CoatingType);

            if (existingCoatingType == null)
            {
                var newCoatingType = new CoatingType();
                {
                    newCoatingType.Description = model.CoatingType;
                    newCoatingType.IsActive    = true;
                }
                operationResult     = _coatingTypeRepository.SaveCoatingType(newCoatingType);
                existingCoatingType = _coatingTypeRepository.GetCoatingType(model.CoatingType);
            }

            var existingSpecificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial(model.SpecificationMaterialDescription);

            if (existingSpecificationMaterial == null)
            {
                var newSpecificationMaterial = new SpecificationMaterial();
                {
                    newSpecificationMaterial.Description = model.SpecificationMaterialDescription;
                    newSpecificationMaterial.IsActive    = true;
                }
                operationResult = _specificationMaterialRepository.SaveSpecificationMaterial(newSpecificationMaterial);
                existingSpecificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial(model.SpecificationMaterialDescription);
            }

            var project = _projectRepository.GetProject(model.ProjectName);

            if (project == null)
            {
                var newProject = new ProjectConverter().ConvertToCreate(model);

                operationResult = _projectRepository.SaveProject(newProject);

                model.ProjectId = operationResult.ReferenceId;
            }
            else
            {
                model.ProjectId = project.ProjectId;
            }

            var newRfq = new RfqConverter().ConvertToDomain(model);

            newRfq.ProjectId = model.ProjectId;

            operationResult = _rfqRepository.SaveRfq(newRfq);

            newRfq.RfqId = operationResult.ReferenceId;

            if (operationResult.Success && model != null)
            {
                foreach (var rfqPart in model.RfqParts)
                {
                    var newProjectPart = new ProjectPartConverter().ConvertToDomain(rfqPart);

                    newProjectPart.RfqId      = operationResult.ReferenceId;
                    newProjectPart.ProjectId  = model.ProjectId;
                    newProjectPart.MaterialId = rfqPart.MaterialId;
                    newProjectPart.MaterialSpecificationId = existingSpecificationMaterial.SpecificationMaterialId;
                    newProjectPart.CoatingTypeId           = existingCoatingType.CoatingTypeId;

                    operationResult = _projectPartRepository.SaveProjectPart(newProjectPart);
                }
            }

            operationResult.ReferenceId = newRfq.RfqId;

            return(Json(operationResult, JsonRequestBehavior.AllowGet));
        }
Exemple #9
0
        public ActionResult Create()
        {
            var model = new RfqViewModel();

            {
                model.RfqNumber = RfqNumber();
            }

            _rfqRepository.RemoveRfqNumber(model.RfqNumber);

            model.Date       = DateTime.Now.ToShortDateString();
            model.RfqDateStr = DateTime.Now.ToShortDateString();
            model.PrintsSent = DateTime.Now.ToShortDateString();
            model.Machining  = "Not Included";

            model.SelectableShipmentTerms = _shipmentTermRepository.GetSelectableShipmentTerms();

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

            model.SelectableShipmentTerms.Insert(0, defaultShipmentTerm);

            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);

            model.SelectableCoatingTypes = _coatingTypeRepository.GetSelectableCoatingTypes();

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

            model.SelectableCoatingTypes.Insert(0, defaultCoatingType);

            model.SelectableSpecificationMaterial = _specificationMaterialRepository.GetSelectableSpecificationMaterials();

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

            model.SelectableSpecificationMaterial.Insert(0, defaultSpecificationMaterial);

            model.SelectableMaterial = _materialRepository.GetSelectableMaterials();

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

            model.SelectableMaterial.Insert(0, defaultMaterial);

            return(View(model));
        }
Exemple #10
0
        /// <summary>
        /// convert rfq to view model
        /// </summary>
        /// <param name="rfq"></param>
        /// <returns></returns>
        public RfqViewModel ConvertToView(Rfq rfq)
        {
            RfqViewModel model = new RfqViewModel();

            var _projectRepository               = new ProjectRepository();
            var _customerDynamicsRepository      = new CustomerDynamicsRepository();
            var _salespersonDynamicsRepository   = new SalespersonDynamicsRepository();
            var _foundryDynamicsRepository       = new FoundryDynamicsRepository();
            var _countryRepository               = new CountryRepository();
            var _shipmentTermRepository          = new ShipmentTermRepository();
            var _coatingTypeRepository           = new CoatingTypeRepository();
            var _specificationMaterialRepository = new SpecificationMaterialRepository();
            var _priceSheetRepository            = new PriceSheetRepository();
            var _projectPartRepository           = new ProjectPartRepository();

            var project               = _projectRepository.GetProject(rfq.ProjectId);
            var dynamicsCustomer      = _customerDynamicsRepository.GetCustomer(rfq.CustomerId);
            var dyanmicsSalesperson   = _salespersonDynamicsRepository.GetSalesperson((dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SLPRSNID)) ? dynamicsCustomer.SLPRSNID : string.Empty);
            var dynamicsFoundry       = _foundryDynamicsRepository.GetFoundry(rfq.FoundryId);
            var country               = _countryRepository.GetCountry(rfq.CountryId);
            var shipmentTerm          = _shipmentTermRepository.GetShipmentTerm(rfq.ShipmentTermId);
            var coatingType           = _coatingTypeRepository.GetCoatingType(rfq.CoatingTypeId);
            var specificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial(rfq.SpecificationMaterialId);
            var quotePriceSheet       = _priceSheetRepository.GetQuotePriceSheetByRfq(rfq.RfqId);
            var productionPriceSheet  = _priceSheetRepository.GetProductionPriceSheetBrRfq(rfq.RfqId);

            model.RfqId                            = rfq.RfqId;
            model.ProjectId                        = rfq.ProjectId;
            model.ProjectName                      = (project != null && !string.IsNullOrEmpty(project.Name)) ? project.Name : "N/A";
            model.RfqNumber                        = (!string.IsNullOrEmpty(rfq.Number)) ? rfq.Number : "N/A";
            model.RfqDate                          = rfq.RfqDate;
            model.RfqDateStr                       = rfq.RfqDate.ToShortDateString();
            model.CustomerId                       = rfq.CustomerId;
            model.CustomerName                     = (dynamicsCustomer != null && !string.IsNullOrEmpty(dynamicsCustomer.SHRTNAME)) ? dynamicsCustomer.SHRTNAME : "N/A";
            model.FoundryId                        = rfq.FoundryId;
            model.FoundryName                      = (dynamicsFoundry != null && !string.IsNullOrEmpty(dynamicsFoundry.VENDSHNM)) ? dynamicsFoundry.VENDSHNM : "N/A";
            model.CountryId                        = rfq.CountryId;
            model.SalespersonId                    = rfq.SalespersonId;
            model.SalespersonName                  = (dyanmicsSalesperson != null) ? dyanmicsSalesperson.SLPRSNFN + " " + dyanmicsSalesperson.SPRSNSLN : "N/A";
            model.CoatingTypeId                    = rfq.CoatingTypeId;
            model.SpecificationMaterialId          = rfq.SpecificationMaterialId;
            model.ContactName                      = rfq.ContactName;
            model.CountryName                      = (country != null && !string.IsNullOrEmpty(country.Name)) ? country.Name : "N/A";
            model.Attention                        = (!string.IsNullOrEmpty(rfq.Attention)) ? rfq.Attention : "N/A";
            model.PrintsSent                       = (rfq.PrintsSent != null) ? rfq.PrintsSent.Value.ToShortDateString() : "N/A";
            model.SentVia                          = rfq.SentVia;
            model.ShipmentTermDescription          = (shipmentTerm != null) ? shipmentTerm.Description : "N/A";
            model.IsMachined                       = rfq.IsMachined;
            model.Packaging                        = rfq.Packaging;
            model.NumberOfSamples                  = rfq.NumberOfSamples;
            model.Details                          = (!string.IsNullOrEmpty(rfq.Attention)) ? rfq.Details : "N/A";
            model.CoatingType                      = (coatingType != null && !string.IsNullOrEmpty(coatingType.Description)) ? coatingType.Description : "N/A";
            model.CoatingTypeId                    = rfq.CoatingTypeId;
            model.SpecificationMaterialId          = rfq.SpecificationMaterialId;
            model.SpecificationMaterialDescription = (specificationMaterial != null && !string.IsNullOrEmpty(specificationMaterial.Description)) ? specificationMaterial.Description : "N/A";
            model.ISIRRequired                     = rfq.ISIRRequired;
            model.SampleCastingAvailable           = rfq.SampleCastingAvailable;
            model.MetalCertAvailable               = rfq.MetalCertAvailable;
            model.CMTRRequired                     = rfq.CMTRRequired;
            model.GaugingRequired                  = rfq.GaugingRequired;
            model.TestBarsRequired                 = rfq.TestBarsRequired;
            model.Notes                            = (!string.IsNullOrEmpty(rfq.Notes)) ? rfq.Notes : "N/A";
            model.IsOpen                           = rfq.IsOpen;
            model.IsHold                           = rfq.IsHold;
            model.HoldExpirationDate               = (rfq.HoldExpirationDate != null) ? rfq.HoldExpirationDate : DateTime.MinValue;
            model.HoldExpirationDateStr            = (rfq.HoldExpirationDate != null) ? rfq.HoldExpirationDate.Value.ToShortDateString() : "N/A";
            model.HoldNotes                        = (!string.IsNullOrEmpty(rfq.HoldNotes)) ? rfq.HoldNotes : "N/A";
            model.IsCanceled                       = rfq.IsCanceled;
            model.CanceledDate                     = (rfq.CanceledDate != null) ? rfq.CanceledDate : DateTime.MinValue;
            model.CanceledDateStr                  = (rfq.CanceledDate != null) ? rfq.CanceledDate.Value.ToShortDateString() : "N/A";
            model.Status                           = rfq.IsOpen ? "Open" : rfq.IsCanceled ? "Canceled" : rfq.IsHold ? "On Hold" : "N/A";
            model.QuotePriceSheetId                = (quotePriceSheet != null) ? quotePriceSheet.PriceSheetId : Guid.Empty;
            model.QuotePriceSheet                  = (quotePriceSheet != null) ? quotePriceSheet.Number : "N/A";
            model.ProductionPriceSheet             = (productionPriceSheet != null) ? productionPriceSheet.Number : "N/A";
            model.MaterialId                       = rfq.MaterialId;
            model.ShipmentTermId                   = rfq.ShipmentTermId;
            model.CancelNotes                      = (!string.IsNullOrEmpty(rfq.CancelNotes)) ? rfq.CancelNotes : "N/A";
            model.HasPriceSheet                    = (quotePriceSheet != null || productionPriceSheet != null) ? true : false;

            model.RfqParts = new List <RfqPartViewModel>();
            var rfqParts = _projectPartRepository.GetProjectParts().Where(x => x.RfqId == rfq.RfqId).ToList();

            foreach (var rfqPart in rfqParts)
            {
                var rfqPartModel = new RfqPartConverter().ConvertToView(rfqPart);
                model.RfqParts.Add(rfqPartModel);
            }

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

            if (_customerDynamicsRepository != null)
            {
                _customerDynamicsRepository.Dispose();
                _customerDynamicsRepository = null;
            }
            if (_salespersonDynamicsRepository != null)
            {
                _salespersonDynamicsRepository.Dispose();
                _salespersonDynamicsRepository = null;
            }

            if (_foundryDynamicsRepository != null)
            {
                _foundryDynamicsRepository.Dispose();
                _foundryDynamicsRepository = null;
            }
            if (_countryRepository != null)
            {
                _countryRepository.Dispose();
                _countryRepository = null;
            }
            if (_shipmentTermRepository != null)
            {
                _shipmentTermRepository.Dispose();
                _shipmentTermRepository = null;
            }
            if (_coatingTypeRepository != null)
            {
                _coatingTypeRepository.Dispose();
                _coatingTypeRepository = null;
            }
            if (_specificationMaterialRepository != null)
            {
                _specificationMaterialRepository.Dispose();
                _specificationMaterialRepository = null;
            }
            if (_priceSheetRepository != null)
            {
                _priceSheetRepository.Dispose();
                _priceSheetRepository = null;
            }
            if (_projectPartRepository != null)
            {
                _projectPartRepository.Dispose();
                _projectPartRepository = null;
            }

            return(model);
        }
Exemple #11
0
        /// <summary>
        /// convert rfq view model to domain
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public Rfq ConvertToDomain(RfqViewModel model)
        {
            Rfq rfq = new Rfq();

            var _countryRepository               = new CountryRepository();
            var _projectRepository               = new ProjectRepository();
            var _coatingTypeRepository           = new CoatingTypeRepository();
            var _specificationMaterialRepository = new SpecificationMaterialRepository();

            var project               = _projectRepository.GetProject((model.ProjectName != null && model.ProjectName != null && model.ProjectName != string.Empty) ? model.ProjectName : "N/A");
            var coatingType           = _coatingTypeRepository.GetCoatingType((model.CoatingType != null && model.CoatingType != null && model.CoatingType != string.Empty) ? model.CoatingType : "N/A");
            var specificationMaterial = _specificationMaterialRepository.GetSpecificationMaterial((model.SpecificationMaterialDescription != null && model.SpecificationMaterialDescription != null && model.SpecificationMaterialDescription != string.Empty) ? model.SpecificationMaterialDescription : "N/A");

            rfq.RfqId                   = model.RfqId;
            rfq.Number                  = model.RfqNumber;
            rfq.RfqDate                 = model.RfqDate;
            rfq.ProjectId               = (project != null) ? project.ProjectId : Guid.Empty;
            rfq.CustomerId              = model.CustomerId;
            rfq.SalespersonId           = model.SalespersonId;
            rfq.FoundryId               = model.FoundryId;
            rfq.ContactName             = model.ContactName;
            rfq.CountryId               = model.CountryId;
            rfq.Attention               = model.Attention;
            rfq.PrintsSent              = DateTime.Parse(model.PrintsSent);
            rfq.SentVia                 = model.SentVia;
            rfq.ShipmentTermId          = model.ShipmentTermId;
            rfq.IsMachined              = model.IsMachined;
            rfq.Packaging               = model.Packaging;
            rfq.NumberOfSamples         = model.NumberOfSamples;
            rfq.Details                 = model.Details;
            rfq.CoatingTypeId           = (coatingType != null) ? coatingType.CoatingTypeId : Guid.Empty;
            rfq.SpecificationMaterialId = (specificationMaterial != null) ? specificationMaterial.SpecificationMaterialId : Guid.Empty;
            rfq.MaterialId              = model.MaterialId;
            rfq.ISIRRequired            = model.ISIRRequired;
            rfq.SampleCastingAvailable  = model.SampleCastingAvailable;
            rfq.MetalCertAvailable      = model.MetalCertAvailable;
            rfq.CMTRRequired            = model.CMTRRequired;
            rfq.GaugingRequired         = model.GaugingRequired;
            rfq.TestBarsRequired        = model.TestBarsRequired;
            rfq.Notes                   = model.Notes;
            rfq.IsOpen                  = model.IsOpen;
            rfq.IsHold                  = model.IsHold;
            rfq.IsCanceled              = model.IsCanceled;
            rfq.HoldExpirationDate      = (model.IsHold) ? model.HoldExpirationDate : null;
            rfq.HoldNotes               = (model.IsHold) ? model.HoldNotes : null;
            rfq.CanceledDate            = (model.IsCanceled) ? model.CanceledDate : null;
            rfq.CancelNotes             = (model.IsCanceled) ? model.CancelNotes : null;

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

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

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

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

            return(rfq);
        }