Exemple #1
0
        static public string K3(int idCompanyMiddleman)
        {
            List <InsuranceZoneOfRegistration> insuranceZoneOfReg = new List <InsuranceZoneOfRegistration>();
            List <bool>             isLegal            = new List <bool>();
            List <CarInsuranceType> insuranceTypeOfCar = new List <CarInsuranceType>();

            try
            {
                insuranceZoneOfReg = InsuranceZoneOfRegistrationDataManipulation.GetMulti();
                isLegal            = new List <bool> {
                    true, false
                };
                insuranceTypeOfCar = CarInsuranceTypeDataManipulation.GetMulti();
            }
            catch
            {
                responseToClient.responseType = ResponseType.Bad;
                responseToClient.responseText = "Виникла помилка при генерації умов.";
                return(js.Serialize(responseToClient));
            }

            foreach (var izor in insuranceZoneOfReg)
            {
                foreach (var il in isLegal)
                {
                    foreach (var itoc in insuranceTypeOfCar)
                    {
                        if (K3DataManipulation.IsConditionExist(izor.Id, il, itoc.Id, idCompanyMiddleman))
                        {
                            var newRowK3 = new K3()
                            {
                                IdInsuranceZoneOfReg = izor.Id,
                                IsLegalEntity        = il,
                                IdCarInsuranceType   = itoc.Id,
                                Value = 0,
                                IdCompanyMiddleman = idCompanyMiddleman,
                            };

                            try
                            {
                                K3DataManipulation.Insert(newRowK3);
                            }
                            catch
                            {
                                responseToClient.responseType = ResponseType.Bad;
                                responseToClient.responseText = $"Виникла помилка при генерації запису для умов: \"{izor.Name}\"; \"{il}\"; \"{itoc.Type}\".";
                                return(js.Serialize(responseToClient));
                            }
                        }
                    }
                }
            }

            responseToClient.responseType = ResponseType.Good;
            responseToClient.responseText = "Генерація даних пройшла успішно.";
            return(js.Serialize(responseToClient));
        }
Exemple #2
0
        public static string K3(string companyName, string middlemanName)
        {
            int idCompany, idMiddleman, idCompanyMiddleman;

            try
            {
                idCompany          = CompanyDataManipulation.GetId(companyName);
                idMiddleman        = MiddlemanDataManipulation.GetId(middlemanName);
                idCompanyMiddleman = CompanyMiddlemanDataManipulation.GetId(companyName, middlemanName);
            }
            catch
            {
                responseToClient.responseType = ResponseType.Bad;
                responseToClient.responseText = "Виникли проблеми з отриманням даних.";
                return(js.Serialize(responseToClient));
            }

            List <K3>            K3Records = K3DataManipulation.GetMulti(idCompanyMiddleman);
            List <TableK3ToSend> K3Table   = new List <TableK3ToSend>();

            //Uncomment for auto generate conditions
            //ConditionGeneration.K3(idCompanyMiddleman);
            //K3Records = K3DataManipulation.GetMulti(idCompanyMiddleman);

            foreach (var k in K3Records)
            {
                TableK3ToSend tempTableRow = new TableK3ToSend();
                tempTableRow.CarZoneOfRegistration = InsuranceZoneOfRegistrationDataManipulation.GetInsuranceZoneOfRegistrationStr(k.IdInsuranceZoneOfReg);
                tempTableRow.IsLegalEntity         = k.IsLegalEntity ? "Юр" : "Фіз";
                tempTableRow.InsuranceTypeOfCar    = CarInsuranceTypeDataManipulation.GetCarInsuranceTypeStr(k.IdCarInsuranceType);
                tempTableRow.Value = k.Value;
                K3Table.Add(tempTableRow);
            }

            List <TitlesToSend> titles = new List <TitlesToSend>();

            titles.Add(FillTitleToSend(name: "CarZoneOfRegistration", titleUkr: "Зона регестрації", titleRus: "Зона регистрации"));
            titles.Add(FillTitleToSend(name: "IsLegalEntity", titleUkr: "Юр / Фіз", titleRus: "Юр / Физ"));
            titles.Add(FillTitleToSend(name: "InsuranceTypeOfCar", titleUkr: "Тип транспорту", titleRus: "Тип транспорта"));
            titles.Add(FillTitleToSend(name: "Value", titleUkr: "Значення", titleRus: "Значение"));

            Dictionary <string, object> dataToSend = new Dictionary <string, object>();

            dataToSend.Add("titles", titles);
            dataToSend.Add("data", K3Table);

            return(js.Serialize(dataToSend));
        }