Пример #1
0
 public VilibidViliborSoapClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(VilibidViliborSoapClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
Пример #2
0
        public async Task <IActionResult> Calculate(string ClientID, string NewRate)
        {
            VilibidViliborSoapClient service = new VilibidViliborSoapClient(new BasicHttpsBinding(BasicHttpsSecurityMode.Transport), new EndpointAddress("https://www.lb.lt/webservices/VilibidVilibor/VilibidVilibor.asmx?WSDL"));
            var          msg      = service.getLatestVilibRateAsync(NewRate);
            const string filename = @"C:\IISProjects\IntrestRatesProvider\web.db";
            var          conn     = new SqliteConnection("Data Source=" + filename);

            try
            {
                conn.Open();
                var              listofclients = new List <Clients>();
                string           query         = "select * from Customer where PersonalID =" + ClientID;
                SqliteCommand    sqlite_cmd    = new SqliteCommand(query, conn);
                SqliteDataReader dr            = sqlite_cmd.ExecuteReader();
                if (!dr.HasRows)
                {
                    dr.Close();
                    conn.Close();
                    return(Error());
                }
                while (dr.Read())
                {
                    listofclients.Add(new Clients
                    {
                        Name       = dr["Name"].ToString(),
                        Surname    = dr["Surname"].ToString(),
                        PersonalID = dr["PersonalID"].ToString()
                    });
                }
                dr.Close();
                Client = listofclients;

                var listofagreements = new List <Agreements>();
                query      = "select * from Agreement a, Customer c where a.CustomerID = c.ID and c.PersonalID =" + ClientID;
                sqlite_cmd = new SqliteCommand(query, conn);
                dr         = sqlite_cmd.ExecuteReader();
                while (dr.Read())
                {
                    string BaseRateCodeOld = dr["Base"].ToString();
                    double MarginCurrent   = Convert.ToDouble(dr["Margin"]);
                    var    msg2            = service.getLatestVilibRateAsync(BaseRateCodeOld);
                    double CurrentInterest = GetRate(Convert.ToDouble(msg2.Result), MarginCurrent);
                    double NewInterest     = GetRate(Convert.ToDouble(msg.Result), MarginCurrent);
                    double Diff            = CurrentInterest - NewInterest;
                    listofagreements.Add(new Agreements
                    {
                        Amount              = Convert.ToInt32(dr["Amount"]),
                        BaseRateCode        = BaseRateCodeOld,
                        Duration            = Convert.ToInt32(dr["Duration"]),
                        Margin              = MarginCurrent,
                        CurrentInterestRate = CurrentInterest,
                        NewInterestRate     = NewInterest,
                        Difference          = Math.Round(Diff, 2)
                    });
                }
                Agreements = listofagreements;
                dr.Close();
                conn.Close();
            }
            catch (Exception)
            {
                return(Error());
            }
            ViewModel mymodel = new ViewModel();

            mymodel.Clients    = Client;
            mymodel.Agreemenat = Agreements;
            return(View(mymodel));
        }
Пример #3
0
 public VilibidViliborSoapClient(EndpointConfiguration endpointConfiguration) :
     base(VilibidViliborSoapClient.GetBindingForEndpoint(endpointConfiguration), VilibidViliborSoapClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }