Exemplo n.º 1
0
        public ActionResult Detail(Guid quoteId)
        {
            var quote = _quoteRepository.GetQuote(quoteId);

            QuoteViewModel model = new QuoteConverter().ConvertToView(quote);

            return(View(model));
        }
Exemplo n.º 2
0
        public ActionResult Index()
        {
            QuoteViewModel model = new QuoteViewModel();

            var tempQuotes = _quoteRepository.GetQuotes().Where(x => x.IsOpen).ToList();

            if (tempQuotes != null && tempQuotes.Count > 0)
            {
                model.Quotes = new List <QuoteViewModel>();

                foreach (var tempQuote in tempQuotes)
                {
                    QuoteViewModel convertedModel = new QuoteConverter().ConvertToListView(tempQuote);
                    model.Quotes.Add(convertedModel);
                }
            }

            return(View(model));
        }
Exemplo n.º 3
0
        public JsonResult GetCanceledQuotes()
        {
            var model = new QuoteViewModel();

            var tempQuotes = _quoteRepository.GetQuotes().Where(x => x.IsCanceled).ToList();

            if (tempQuotes != null && tempQuotes.Count > 0)
            {
                model.Quotes = new List <QuoteViewModel>();

                foreach (var quote in tempQuotes)
                {
                    QuoteViewModel convertedModel = new QuoteConverter().ConvertToListView(quote);
                    model.Quotes.Add(convertedModel);
                }
            }

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        /// <summary>
        /// admin dashboard
        /// </summary>
        /// <returns></returns>
        public ActionResult Admin()
        {
            var model = new DashboardViewModel();
            var _db   = new SouthlandDb();

            var currentDate = DateTime.Today.AddMonths(-1);

            var projects = new List <ProjectViewModel>();

            var tempProjects = _projectRepository.GetProjects().Where(x => x.IsHold).ToList();

            if (tempProjects != null && tempProjects.Count > 0)
            {
                foreach (var tempProject in tempProjects)
                {
                    ProjectViewModel convertedModel = new ProjectConverter().ConvertToListView(tempProject);

                    projects.Add(convertedModel);
                }
            }

            model.OnHoldProjects = projects;

            var rfqs = new List <RfqViewModel>();

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

            if (tempRfqs != null && tempRfqs.Count > 0)
            {
                foreach (var tempRfq in tempRfqs)
                {
                    RfqViewModel convertedModel = new RfqConverter().ConvertToListView(tempRfq);

                    rfqs.Add(convertedModel);
                }
            }

            model.OnHoldRfqs = rfqs;

            var quotes = new List <QuoteViewModel>();

            var tempQuotes = _quoteRepository.GetQuotes().Where(x => x.IsHold).ToList();

            if (tempQuotes != null && tempQuotes.Count > 0)
            {
                foreach (var tempQuote in tempQuotes)
                {
                    QuoteViewModel convertedModel = new QuoteConverter().ConvertToListView(tempQuote);

                    quotes.Add(convertedModel);
                }
            }

            model.OnHoldQuotes = quotes;

            var customerOrders = new List <CustomerOrderViewModel>();

            var tempCustomerOrders = _customerOrderRepository.GetCustomerOrders().Where(x => x.IsHold).ToList();

            if (tempCustomerOrders != null && tempCustomerOrders.Count > 0)
            {
                foreach (var tempCustomerOrder in tempCustomerOrders)
                {
                    CustomerOrderViewModel convertedModel = new CustomerOrderConverter().ConvertToListView(tempCustomerOrder);

                    customerOrders.Add(convertedModel);
                }
            }

            model.OnHoldCustomerOrders = customerOrders;

            var foundryOrders = new List <FoundryOrderViewModel>();

            var tempFoundryOrders = _foundryOrderRepository.GetFoundryOrders().Where(x => x.IsHold).ToList();

            if (tempFoundryOrders != null && tempFoundryOrders.Count > 0)
            {
                foreach (var tempFoundryOrder in tempFoundryOrders)
                {
                    FoundryOrderViewModel convertedModel = new FoundryOrderConverter().ConvertToListView(tempFoundryOrder);

                    foundryOrders.Add(convertedModel);
                }
            }

            model.OnHoldFoundryOrders = foundryOrders;

            var packingLists = new List <PackingListViewModel>();

            var tempPackingLists = _packingListRepository.GetPackingLists().Where(x => !x.IsClosed).ToList();

            if (tempPackingLists != null && tempPackingLists.Count > 0)
            {
                foreach (var tempPackingList in tempPackingLists)
                {
                    PackingListViewModel convertedModel = new PackingListConverter().ConvertToListView(tempPackingList);

                    packingLists.Add(convertedModel);
                }
            }

            model.OpenPackingLists = packingLists;

            return(View(model));
        }
Exemplo n.º 5
0
        public JsonResult Edit(QuoteViewModel model)
        {
            var operationResult = new OperationResult();

            var quoteToUpdate = new QuoteConverter().ConvertToDomain(model);

            operationResult = _quoteRepository.UpdateQuote(quoteToUpdate);

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

                var rfq               = _rfqRepository.GetRfq(quoteToUpdate.RfqId);
                var rfqId             = quoteToUpdate.RfqId;
                var priceSheetId      = quoteToUpdate.PriceSheetId;
                var quoteId           = model.QuoteId;
                var projectId         = quoteToUpdate.ProjectId;
                var customerAddressId = quoteToUpdate.CustomerAddressId;
                var foundryId         = (rfq != null) ? rfq.FoundryId : string.Empty;
                var htsNumberId       = model.HtsNumberId;
                var shipmentTermId    = model.ShipmentTermId;
                var paymentTermId     = model.PaymentTermId;
                var materialId        = quoteToUpdate.MaterialId;
                var coatingTypeId     = quoteToUpdate.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.MaterialSpecificationId = 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);
                            }
                        }
                    }
                }

                var existingParts = _projectPartRepository.GetProjectParts().Where(x => x.QuoteId == quoteId).ToList();

                if (existingParts != null)
                {
                    foreach (var existingPart in existingParts)
                    {
                        var part = model.QuoteParts.FirstOrDefault(x => x.PartNumber == existingPart.Number);

                        if (part == null)
                        {
                            existingPart.QuoteId = null;
                            operationResult      = _projectPartRepository.UpdateProjectPart(existingPart);
                        }
                    }
                }

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

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 6
0
        public ActionResult Edit(Guid quoteId)
        {
            QuoteViewModel model = new QuoteViewModel();

            var currentQuote = _quoteRepository.GetQuote(quoteId);

            model = new QuoteConverter().ConvertToView(currentQuote);

            model.SelectableShipmentTerms = _shipmentTermRepository.GetSelectableShipmentTerms();

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

            model.SelectableShipmentTerms.Insert(0, defaultShipmentTerm);

            model.SelectablePaymentTerms = _paymentTermRepository.GetSelectablePaymentTerms();

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

            model.SelectablePaymentTerms.Insert(0, defaultPaymentTerm);

            model.SelectableMaterial = _materialRepository.GetSelectableMaterials();

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

            model.SelectableMaterial.Insert(0, defaultMaterial);

            model.SelectableCoatingTypes = _coatingTypeRepository.GetSelectableCoatingTypes();

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

            model.SelectableCoatingTypes.Insert(0, defaultCoatingType);

            var htsNumbers = _htsNumberRepository.GetSelectableHtsNumbers();

            var defaultHtsNumber = new SelectListItem()
            {
                Text  = "--Select Hts Number--",
                Value = null
            };

            htsNumbers.Insert(0, defaultHtsNumber);

            model.SelectableHtsNumbers = htsNumbers;

            model.CurrentUser = User.Identity.Name;

            return(View(model));
        }
Exemplo n.º 7
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));
        }
Exemplo n.º 8
0
        public ActionResult Convert(Guid rfqId)
        {
            var currentRfq = _rfqRepository.GetRfq(rfqId);

            QuoteViewModel model = new QuoteConverter().ConvertToView(currentRfq);

            model.QuoteNumber = QuoteNumber();

            _quoteRepository.RemoveQuoteNumber(model.QuoteNumber);

            model.SelectableCustomerAddresses = _customerAddressDynamicsRepository.GetSelectableCustomerAddresses(model.CustomerId);

            model.SelectableShipmentTerms = _shipmentTermRepository.GetSelectableShipmentTerms();

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

            model.SelectableShipmentTerms.Insert(0, defaultShipmentTerm);

            model.SelectablePaymentTerms = _paymentTermRepository.GetSelectablePaymentTerms();

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

            model.SelectablePaymentTerms.Insert(0, defaultPaymentTerm);

            model.SelectableMaterial = _materialRepository.GetSelectableMaterials();

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

            model.SelectableMaterial.Insert(0, defaultMaterial);

            model.SelectableCoatingTypes = _coatingTypeRepository.GetSelectableCoatingTypes();

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

            model.SelectableCoatingTypes.Insert(0, defaultCoatingType);

            model.SelectableHtsNumbers = _htsNumberRepository.GetSelectableHtsNumbers();

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

            model.SelectableHtsNumbers.Insert(0, defaultHtsNumber);

            return(View(model));
        }