예제 #1
0
        public ActionResult Detail(Guid rfqId)
        {
            var rfq = _rfqRepository.GetRfq(rfqId);

            RfqViewModel model = new RfqConverter().ConvertToView(rfq);

            return(View(model));
        }
예제 #2
0
        public JsonResult GetRfqByProject(string projectName)
        {
            var project = _projectRepository.GetProject(projectName);

            var rfq = _rfqRepository.GetRfqByProject((project != null) ? project.ProjectId : Guid.Empty);

            RfqViewModel model = new RfqConverter().ConvertToView(rfq);

            return(Json(model, JsonRequestBehavior.AllowGet));
        }
예제 #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));
        }
예제 #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));
        }
예제 #5
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));
        }
예제 #6
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));
        }
예제 #7
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));
        }
예제 #8
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));
        }