public DetailsViewModel(int id)
        {
            var orderToCarInsure = CurrentDb.OrderToCarInsure.Where(m => m.Id == id).FirstOrDefault();

            if (orderToCarInsure != null)
            {
                _orderToCarInsure = orderToCarInsure;

                var merchant = CurrentDb.Merchant.Where(m => m.Id == orderToCarInsure.MerchantId).FirstOrDefault();
                if (merchant != null)
                {
                    _merchant = merchant;
                }

                var orderToCarInsureOfferCompany = CurrentDb.OrderToCarInsureOfferCompany.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                var insureOfferCompanys          = CurrentDb.Company.ToList();
                if (orderToCarInsureOfferCompany != null)
                {
                    _orderToCarInsureOfferCompany = orderToCarInsureOfferCompany;

                    foreach (var m in _orderToCarInsureOfferCompany)
                    {
                        var insureOfferCompany = insureOfferCompanys.Where(q => q.Id == m.InsuranceCompanyId).FirstOrDefault();
                        if (insureOfferCompany != null)
                        {
                            m.InsuranceCompanyName   = insureOfferCompany.Name;
                            m.InsuranceCompanyImgUrl = insureOfferCompany.ImgUrl;
                        }
                    }
                }

                var orderToCarInsureOfferKind = CurrentDb.OrderToCarInsureOfferKind.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                var carKinds = CurrentDb.CarKind.ToList();
                if (orderToCarInsureOfferKind != null)
                {
                    _orderToCarInsureOfferKind = orderToCarInsureOfferKind;

                    foreach (var m in _orderToCarInsureOfferKind)
                    {
                        var carKind = carKinds.Where(q => q.Id == m.KindId).FirstOrDefault();
                        if (carKind != null)
                        {
                            m.KindName = carKind.Name;
                            m.KindUnit = carKind.InputUnit;
                        }
                    }
                }

                _bizProcessesAuditDetails = BizFactory.BizProcessesAudit.GetDetails(Enumeration.BizProcessesAuditType.OrderToCarInsure, id);
            }
        }
Esempio n. 2
0
        public DealtViewModel(int id)
        {
            var bizProcessesAudit = BizFactory.BizProcessesAudit.ChangeCarInsureOfferDealtStatus(this.Operater, id, Enumeration.CarInsureOfferDealtStatus.InOffer, "报价中");

            if (bizProcessesAudit != null)
            {
                _bizProcessesAudit = bizProcessesAudit;

                if (_bizProcessesAudit.Auditor.Value != this.Operater)
                {
                    this.IsHasOperater = true;
                    this.OperaterName  = SysFactory.SysUser.GetFullName(_bizProcessesAudit.Auditor.Value);
                }



                var orderToCarInsure = CurrentDb.OrderToCarInsure.Where(m => m.Id == bizProcessesAudit.AduitReferenceId).FirstOrDefault();
                if (orderToCarInsure != null)
                {
                    _orderToCarInsure = orderToCarInsure;

                    var merchant = CurrentDb.Merchant.Where(m => m.Id == orderToCarInsure.MerchantId).FirstOrDefault();
                    if (merchant != null)
                    {
                        _merchant = merchant;
                    }

                    var orderToCarInsureOfferCompany = CurrentDb.OrderToCarInsureOfferCompany.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                    var insureOfferCompanys          = CurrentDb.Company.ToList();
                    if (orderToCarInsureOfferCompany != null)
                    {
                        _orderToCarInsureOfferCompany = orderToCarInsureOfferCompany;

                        foreach (var m in _orderToCarInsureOfferCompany)
                        {
                            var insureOfferCompany = insureOfferCompanys.Where(q => q.Id == m.InsuranceCompanyId).FirstOrDefault();
                            if (insureOfferCompany != null)
                            {
                                m.InsuranceCompanyName   = insureOfferCompany.Name;
                                m.InsuranceCompanyImgUrl = insureOfferCompany.ImgUrl;
                            }
                        }
                    }

                    var orderToCarInsureOfferKind = CurrentDb.OrderToCarInsureOfferKind.Where(m => m.OrderId == orderToCarInsure.Id).ToList();
                    var carKinds = CurrentDb.CarKind.ToList();
                    if (orderToCarInsureOfferKind != null)
                    {
                        _orderToCarInsureOfferKind = orderToCarInsureOfferKind;

                        var isHasCompulsoryPrice = _orderToCarInsureOfferKind.Where(m => m.KindId == 1).FirstOrDefault();
                        if (isHasCompulsoryPrice != null)
                        {
                            _isHasCompulsoryPrice = true;
                        }

                        var isHasTravelTaxPrice = _orderToCarInsureOfferKind.Where(m => m.KindId == 2).FirstOrDefault();
                        if (isHasTravelTaxPrice != null)
                        {
                            _isHasTravelTaxPrice = true;
                        }

                        var isHasCommercialPrice = _orderToCarInsureOfferKind.Where(m => m.KindId >= 3).FirstOrDefault();
                        if (isHasCommercialPrice != null)
                        {
                            _isHasCommercialPrice = true;
                        }


                        foreach (var m in _orderToCarInsureOfferKind)
                        {
                            var carKind = carKinds.Where(q => q.Id == m.KindId).FirstOrDefault();
                            if (carKind != null)
                            {
                                m.KindName = carKind.Name;
                                m.KindUnit = carKind.InputUnit;
                            }
                        }
                    }
                }
            }
        }