Exemple #1
0
        //api todayAct
        public static async Task <HttpResponseMessage> GetLogToday()
        {
            AccountFull ac     = (AccountFull)Application.Current.Properties["Account"];
            int         id     = ac.Id_account;
            DateTime    today  = DateTime.Now;
            string      weburl = prefixApi + $"activity/getdestinationbyaccount/{id}/{today.Date.ToString("yyyy-MM-dd")}";
            //string weburl = "http://localhost:61948/Auth";
            //string weburl = "http://192.168.137.1:61948/Auth";

            HttpClient client = new HttpClient();

            client.MaxResponseContentBufferSize = 256000;
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            // UserPost contentjson = new UserPost { email = user.email, password = user.password };
            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Application.Current.Properties["token"].ToString());

            //var content = new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, "application/json");

            try
            {
                HttpResponseMessage response = await client.GetAsync(weburl);

                // this result string should be something like: "{"token":"rgh2ghgdsfds"}"
                //var result = await response.Content.ReadAsStringAsync();
                //return JsonConvert.DeserializeObject<string>(result);
                return(response);
            }
            catch (Exception e)
            {
                return(new HttpResponseMessage {
                    StatusCode = System.Net.HttpStatusCode.ServiceUnavailable
                });
            }
        }
Exemple #2
0
        //api past
        public static async Task <HttpResponseMessage> GetLogPast()
        {
            AccountFull ac     = (AccountFull)Application.Current.Properties["Account"];
            int         id     = ac.Id_account;
            DateTime    today  = DateTime.Now;
            string      weburl = prefixApi + $"activity/getallactivitiesofstudentbeforedate/{id}/{today.Date.ToString("yyyy-MM-dd")}";

            HttpClient client = new HttpClient();

            client.MaxResponseContentBufferSize = 256000;
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));

            client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Application.Current.Properties["token"].ToString());

            try
            {
                HttpResponseMessage response = await client.GetAsync(weburl);

                //var result = await response.Content.ReadAsStringAsync();
                //return JsonConvert.DeserializeObject<string>(result);
                return(response);
            }
            catch (Exception e)
            {
                return(new HttpResponseMessage {
                    StatusCode = System.Net.HttpStatusCode.ServiceUnavailable
                });
            }
        }
Exemple #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NewStateLine"/> class.
 /// </summary>
 /// <param name="statementSequenceNumber">The sequence number statement of account on paper.</param>
 /// <param name="account">The account.</param>
 /// <param name="balance">The new balance.</param>
 /// <param name="date">The new balance date.</param>
 public NewStateLine(
     StatementSequenceNumber statementSequenceNumber,
     AccountFull account,
     Amount balance,
     Date date)
 {
     StatementSequenceNumber = statementSequenceNumber;
     Account = account;
     Balance = balance;
     Date    = date;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="TransactionPart3Line"/> class.
 /// </summary>
 /// <param name="sequenceNumber">The continuous sequence number.</param>
 /// <param name="sequenceNumberDetail">The detail number.</param>
 /// <param name="otherAccountNumberAndCurrency">The counterparty's account number and currency code.</param>
 /// <param name="otherAccountName">The counterparty's name.</param>
 /// <param name="message">The communication.</param>
 public TransactionPart3Line(
     SequenceNumber sequenceNumber,
     SequenceNumberDetail sequenceNumberDetail,
     AccountFull otherAccountNumberAndCurrency,
     AccountName otherAccountName,
     Message message)
 {
     SequenceNumber                = sequenceNumber;
     SequenceNumberDetail          = sequenceNumberDetail;
     OtherAccountNumberAndCurrency = otherAccountNumberAndCurrency;
     OtherAccountName              = otherAccountName;
     Message = message;
 }
Exemple #5
0
        public async void LoginAction(Account a)
        {
            IsBusy = true;

            //// User a = new User { EMAIL = "*****@*****.**", PASSWORD ="******", ROLE = "user" };
            //User a = new User();
            //a.EMAIL = "*****@*****.**";
            //a.PASSWORD = "******";
            //a.ROLE = "user";


            //Task t = Task.Run(async () =>
            //{
            AccountFull accountFull = await new RestService().Login(a);
            string      token       = accountFull.Token;

            if (token != null)
            {
                Application.Current.Properties["Account"] = accountFull;
                Application.Current.Properties["token"]   = accountFull.Token.ToString();

                await Application.Current.SavePropertiesAsync();
            }
            else
            {
            }


            //TODO - perform your login action + navigate to the next page

            //Simulate an API call to show busy/progress indicator
            // Task.Delay(20000).ContinueWith((t) => IsBusy = false);

            //Show the Cancel button after X seconds
            //Task.Delay(5000).ContinueWith((t) => IsShowCancel = true);

            //await Task.Delay(3000).ContinueWith((t) => IsBusy = false);
            //if(this._email.Length > 5 )
            //{
            //    await Navigation.PushModalAsync(new NavigationPage(new MainPage()));
            //}
            //else
            //{
            //    await Navigation.PushModalAsync(new NavigationPage(new ResetPassword()));
            //}
        }
Exemple #6
0
        //api login

        public async Task <AccountFull> Login(Account account)
        {
            string weburl = prefixApi + "login";
            //string weburl = "http://localhost:61948/Auth";
            //string weburl = "http://192.168.137.1:61948/Auth";
            // UserPost contentjson = new UserPost { email = user.email, password = user.password };
            var content = JsonConvert.SerializeObject(account);
            var conten  = new StringContent(content, Encoding.UTF8, "application/json");

            client = new HttpClient();
            client.MaxResponseContentBufferSize = 256000;
            client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
            //client.DefaultRequestHeaders.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", Application.Current.Properties["token"].ToString());
            try
            {
                HttpResponseMessage response = await client.PostAsync(weburl, conten);

                //var result = await response.Content.ReadAsStringAsync();
                //return JsonConvert.DeserializeObject<string>(result);
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    var result = await response.Content.ReadAsStringAsync();

                    AccountFull acc = JsonConvert.DeserializeObject <AccountFull>(result);
                    return(acc);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception e)
            {
                return(null);
            }
        }