Exemple #1
0
        public JsonResult Delete(Guid rfqId)
        {
            var operationResult = new OperationResult();

            var existingRfq = _rfqRepository.GetRfq(rfqId);

            if (existingRfq != null)
            {
                var rfqCount = _rfqRepository.GetRfqs().Where(x => x.ProjectId == existingRfq.ProjectId).Count();

                if (rfqCount == 1)
                {
                    operationResult = _projectRepository.DeleteProject(existingRfq.ProjectId);
                }

                var projectParts = _projectPartRepository.GetProjectParts().Where(x => x.RfqId == rfqId).ToList();

                if (projectParts != null && projectParts.Count() > 0)
                {
                    foreach (var projectPart in projectParts)
                    {
                        var partDrawings = _projectPartRepository.GetProjectPartDrawings(projectPart.ProjectPartId);

                        if (partDrawings != null && partDrawings.Count() > 0)
                        {
                            foreach (var partDrawing in partDrawings)
                            {
                                operationResult = _projectPartRepository.DeleteProjectPartDrawing(partDrawing.ProjectPartDrawingId);
                            }
                        }

                        var partLayouts = _projectPartRepository.GetProjectPartLayouts(projectPart.ProjectPartId);

                        if (partLayouts != null && partLayouts.Count() > 0)
                        {
                            foreach (var partLayout in partLayouts)
                            {
                                operationResult = _projectPartRepository.DeleteProjectPartLayout(partLayout.ProjectPartLayoutId);
                            }
                        }

                        operationResult = _projectPartRepository.DeleteProjectPart(projectPart.ProjectPartId);
                    }
                }

                operationResult = _rfqRepository.DeleteRfq(rfqId);
            }

            return(Json(operationResult, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public JsonResult DeleteDrawing(Guid partId, Guid drawingId)
        {
            var operationResult = new OperationResult();

            var projectDrawingToDelete = _projectPartRepository.GetProjectPartDrawing(drawingId);

            if (projectDrawingToDelete != null)
            {
                operationResult = _projectPartRepository.DeleteProjectPartDrawing(drawingId);

                if (operationResult.Success)
                {
                    var latestDrawing = _projectPartRepository.GetProjectPartDrawings(partId).OrderByDescending(x => x.CreatedDate).FirstOrDefault();

                    if (latestDrawing != null)
                    {
                        latestDrawing.IsLatest = true;
                    }

                    operationResult = _projectPartRepository.UpdateProjectPartDrawing(latestDrawing);
                }
            }
            else
            {
                var drawingToDelete = _partRepository.GetPartDrawing(drawingId);

                if (drawingToDelete != null)
                {
                    operationResult = _partRepository.DeletePartDrawing(drawingToDelete);

                    if (operationResult.Success)
                    {
                        var latestDrawing = _partRepository.GetPartDrawings(partId).OrderByDescending(x => x.CreatedDate).FirstOrDefault();

                        if (latestDrawing != null)
                        {
                            latestDrawing.IsLatest = true;

                            operationResult = _partRepository.UpdatePartDrawing(latestDrawing);
                        }
                    }
                }
            }

            return(Json(operationResult, JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        private OperationResult ConvertProjectPartsToParts(Guid priceSheetId)
        {
            var operationResult = new OperationResult();

            var projectParts = _projectPartRepository.GetProjectParts().Where(x => x.PriceSheetId == priceSheetId).ToList();

            if (projectParts != null && projectParts.Count > 0)
            {
                foreach (var projectPart in projectParts)
                {
                    var existingPart = _partRepository.GetPart(projectPart.PartId);

                    if (existingPart != null)
                    {
                        PartOperationModel convertedModel = new PartOperationConverter().ConvertFromProjectPart(projectPart);

                        Part part = new PartConverter().ConvertToUpdatePart(convertedModel);

                        operationResult = _partRepository.UpdatePart(part);

                        var existingProject = _projectRepository.GetProject(projectPart.ProjectId);

                        if (existingProject != null)
                        {
                            if (existingProject.Parts.FirstOrDefault(x => x.PartId == part.PartId) == null)
                            {
                                existingProject.Parts.Add(part);
                                operationResult = _projectRepository.UpdateProject(existingProject);
                            }
                        }

                        IV00101_Part_Master partMaster = new PartConverter().ConvertToUpdateMaster(convertedModel);

                        operationResult = _partDynamicsRepository.UpdatePartMaster(partMaster);

                        IV00105_Part_Currency partCurrency = new PartConverter().ConvertToUpdateCurrency(convertedModel);

                        operationResult = _partDynamicsRepository.UpdatePartCurrency(partCurrency);
                    }
                    else
                    {
                        var existingProject = _projectRepository.GetProject(projectPart.ProjectId);

                        if (existingProject != null)
                        {
                            Part part = new PartConverter().ConvertToCreatePart(projectPart);
                            existingProject.Parts.Add(part);
                            operationResult = _projectRepository.UpdateProject(existingProject);
                            existingPart    = existingProject.Parts.FirstOrDefault(x => x.Number == part.Number);
                        }

                        projectPart.PartId = existingPart.PartId;

                        operationResult = _projectPartRepository.UpdateProjectPart(projectPart);

                        IV00101_Part_Master partMaster = new PartConverter().ConvertToCreateMaster(projectPart);

                        operationResult = _partDynamicsRepository.SavePartMaster(partMaster);

                        IV00105_Part_Currency partCurrency = new PartConverter().ConvertToCreateCurrency(projectPart);

                        operationResult = _partDynamicsRepository.SavePartCurrency(partCurrency);

                        IV00107_Part_Price_Option partPriceOption = new PartConverter().ConvertToCreatePriceOption(projectPart);

                        operationResult = _partDynamicsRepository.SavePartPriceOption(partPriceOption);

                        IV00108_Part_Price partPrice = new PartConverter().ConvertToCreatePrice(projectPart);

                        operationResult = _partDynamicsRepository.SavePartPrice(partPrice);

                        IV00103_Part_Vendor_Master partVendor = new PartConverter().ConvertToCreateVendor(projectPart);

                        operationResult = _partDynamicsRepository.SavePartVendorMaster(partVendor);

                        var projectPartDrawings = _projectPartRepository.GetProjectPartDrawings(projectPart.ProjectPartId);

                        if (projectPartDrawings != null && projectPartDrawings.Count > 0)
                        {
                            foreach (var projectPartDrawing in projectPartDrawings)
                            {
                                operationResult = _projectPartRepository.DeleteProjectPartDrawing(projectPartDrawing.ProjectPartDrawingId);
                            }
                        }

                        var projectPartLayouts = _projectPartRepository.GetProjectPartLayouts(projectPart.ProjectPartId);

                        if (projectPartLayouts != null && projectPartLayouts.Count > 0)
                        {
                            foreach (var projectPartLayout in projectPartLayouts)
                            {
                                operationResult = _projectPartRepository.DeleteProjectPartLayout(projectPartLayout.ProjectPartLayoutId);
                            }
                        }
                    }
                }
            }

            return(operationResult);
        }