示例#1
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!APIHandler.currentlyLogged)
        {
            Response.Redirect("~/Account/Login");
        }

        literalRuta.Text = APIHandler.getCurrentDir();

        if (!IsPostBack || APIHandler.refresh)
        {
            fillExplorer(); APIHandler.refresh = false;
        }

        if (APIHandler.pastebinFull)
        {
            btnPegar.Visible = true;
        }
        else
        {
            btnPegar.Visible = false;
        }
    }
示例#2
0
        /// <summary>
        /// Method that is called when a user clicks on confirm for creating a new role
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private async void ContentDialog_OnConfirmClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            var error = vm.CheckRoleForErrors();

            ErrorTextBlock.Text = vm.SetErrorText(error);
            if (error == Constants.RoleErrors.OK)
            {
                await APIHandler <Role> .PostOne("Roles", new Role(0, EnterRoleBox.Text));

                await Data.UpdateRoles();

                if (VMHandler.CreateEmployeeVm != null)
                {
                    await VMHandler.CreateEmployeeVm.LoadDataAsync();
                }
                if (VMHandler.EmployeesPageVm != null)
                {
                    await VMHandler.EmployeesPageVm.LoadRolesAsync();
                }
                args.Cancel = false;
            }
            args.Cancel = true;
        }
示例#3
0
    protected void btnPopupConfirmacionSI_Click(object sender, EventArgs e)
    {
        string stringResponse = APIHandler.pasteFile();

        XmlDocument xmlResponse = new XmlDocument();

        xmlResponse.LoadXml(stringResponse);

        string msg = xmlHandler.handle_WDriveMessage(xmlResponse);

        if (msg.Equals("OK"))
        {
            displayAlert("Archivo pegado con éxito.");
            if (APIHandler.movingAction)
            {
                APIHandler.pastebinFull = false;
            }
        }
        else
        {
            displayAlert(msg);
        }
    }
示例#4
0
 async void OnRefresh(object sender, EventArgs e)
 {
     if (Utils.Utils.hasInternetAccess())
     {
         // atualizar currencies
         try
         {
             APIHandler api = new APIHandler();
             api.UpdateCurrencies();
             return;
         }
         catch (Exception exception)
         {
             // show dialog
             //await DisplayAlert("Warning", "The API is currently unavailable. Please Try Again", "OK");
         }
     }
     else
     {
         // no internet show access
         await DisplayAlert("Warning", "No Internet Access. Please Connect to the Internet.", "OK");
     }
 }
示例#5
0
        private async Task UpdateTrack(LocalFile file)
        {
            AudioManager.SetTrack(file);

            if (FileLoader.Files.IndexOf(file) != AudioManager.CurrentTrackID)
            {
                var task = await APIHandler.SendRequest(ApiRequestType.Search,
                                                        file.FileName) as SearchResponse;

                StatisticsWindow.Update(task);
            }

            AudioManager.CurrentTrackID = FileLoader.Files.IndexOf(file);

            MainWindowController.SetTimelineValues(0,
                                                   AudioManager.AudioProperties.PlaybackLength);

            MainWindowController.Update();

            PlayOrPauseButtonUI.Content = Constants.PAUSE_STATE;

            CurrentTrackTextBlock.Text = file.FileName;
        }
示例#6
0
    protected void btnPegar_Click(object sender, EventArgs e)
    {
        if (!APIHandler.pastebinFull)
        {
            displayAlert("No hay archivos para pegar.");
            return;
        }

        bool existe = existe_archivo(APIHandler.pastingFile);

        if (existe)
        {
            desplegarConfirmacion("El archivo ya existe. ¿Desea reemplazarlo?");
            return;
        }

        string stringResponse = APIHandler.pasteFile();

        XmlDocument xmlResponse = new XmlDocument();

        xmlResponse.LoadXml(stringResponse);

        string msg = xmlHandler.handle_WDriveMessage(xmlResponse);

        if (msg.Equals("OK"))
        {
            displayAlert("Archivo pegado con éxito.");
            if (APIHandler.movingAction)
            {
                APIHandler.pastebinFull = false;
            }
        }
        else
        {
            displayAlert(msg);
        }
    }
示例#7
0
        public async Task <ActionResult> Register(string email, string password)
        {
            var userJson = new UserJson();

            if (await UserManager.FindByEmailAsync(email) != null)
            {
                return(View("User", userJson));
            }
            var user = new ApplicationUser {
                UserName = email, Email = email
            };
            var result = await UserManager.CreateAsync(user, password);

            if (result.Succeeded)
            {
                var handler = new APIHandler
                {
                    Action = "user/create/",
                    Values = new JavaScriptSerializer().Serialize(new
                    {
                        username    = email,
                        name        = email,
                        permissions = new List <string> {
                            "appFlag"
                        }
                    })
                };
                //To get the Result about the register from the api, change the given model to the view
                var json = new Json {
                    JsonString = await handler.RequestPostAsync()
                };
                userJson = new UserJson {
                    UserId = user.Id, Email = email
                };
            }
            return(View("User", userJson));
        }
示例#8
0
    protected void btnPopupSubirArchivo_Click(object sender, EventArgs e)
    {
        string archivo   = Path.GetFileName(fileUpload.FileName);
        string contenido = System.Text.Encoding.UTF8.GetString(fileUpload.FileBytes);

        string stringResponse = APIHandler.createFile(archivo, contenido);

        XmlDocument xmlResponse = new XmlDocument();

        xmlResponse.LoadXml(stringResponse);

        string msg = xmlHandler.handle_WDriveMessage(xmlResponse);

        if (msg.Equals("OK"))
        {
            displayAlert("Archivo subido con éxito.");
        }
        else
        {
            displayAlert(msg);
        }

        fillExplorer();
    }
示例#9
0
    protected void btnPopupCrearArchivo_Click(object sender, EventArgs e)
    {
        string archivo   = txtArchivo.Text;
        string contenido = txtContenido.Text;

        string stringResponse = APIHandler.createFile(archivo, contenido);

        XmlDocument xmlResponse = new XmlDocument();

        xmlResponse.LoadXml(stringResponse);

        string msg = xmlHandler.handle_WDriveMessage(xmlResponse);

        if (msg.Equals("OK"))
        {
            displayAlert("Archivo creado con éxito.");
        }
        else
        {
            displayAlert(msg);
        }

        fillExplorer();
    }
示例#10
0
    protected bool existe_archivo(string filename)
    {
        string stringResponse = APIHandler.exists(filename);

        XmlDocument xmlResponse = new XmlDocument();

        xmlResponse.LoadXml(stringResponse);

        string msg = xmlHandler.handle_ExistMessage(xmlResponse);

        if (msg.Equals("false"))
        {
            return(false);
        }
        if (msg.Equals("true"))
        {
            return(true);
        }
        else
        {
            displayAlert("Error verificando existencia del archivo.");
        }
        return(true);
    }
        public async Task <ViewResult> DataLoad()
        {
            APIHandler   webHandler = new APIHandler();
            HospitalData result     = webHandler.GetHospitals();

            foreach (var item in result.data)
            {
                if (dbContext.Hospitals.Count() == 0)
                {
                    dbContext.Hospitals.Add(item);
                }
            }
            foreach (var item in dbContext.Hospitals)
            {
                Provider provider = new Provider();
                Location location = new Location();
                provider.provider_id                          = item.provider_id;
                provider.provider_name                        = item.provider_name;
                provider.provider_street_address              = item.provider_street_address;
                provider.provider_zip_code                    = item.provider_zip_code;
                provider.total_discharges                     = item.total_discharges;
                provider.drg_definition                       = item.drg_definition;
                provider.average_covered_charges              = item.average_covered_charges;
                provider.average_medicare_payments            = item.average_medicare_payments;
                provider.average_medicare_payments_2          = item.average_medicare_payments_2;
                location.provider_city                        = item.provider_city;
                location.provider_state                       = item.provider_state;
                location.hospital_referral_region_description = item.hospital_referral_region_description;
                dbContext.Locations.Add(location);
                provider.Location = location;
                dbContext.Providers.Add(provider);
            }
            await dbContext.SaveChangesAsync();

            return(View("Index", result));
        }
示例#12
0
        private async void ContentDialog_OnConfirmClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            try
            {
                if (viewModel.CheckErrors())
                {
                    Category c = await APIHandler <Category> .PostOne("categories", new Category(EnterCategoryBox.Text));

                    VMHandler.AddItemViewModel.LoadDataAsync();
                    VMHandler.AddItemViewModel.Category = c;

                    args.Cancel = false;
                }
                else
                {
                    args.Cancel = true;
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
示例#13
0
        /// <summary>
        /// Initializes the <see cref="Loader"/> class.
        /// </summary>
        internal static void Init()
        {
            if (Loader.Initialized)
            {
                return;
            }

            Loader.Random = new LogicRandom();

            LogicCommandManager.Init();
            MessageManager.Init();

            Fingerprint.Init();
            CSV.Init();
            Globals.Init();

            if (Settings.Database == DBMS.Mongo)
            {
                Mongo.Init();
            }

            Connections.Init();
            Avatars.Init();
            Alliances.Init();
            Battles.Init();

            ServerConnection.Init();
            APIHandler.Init();

            ServerTimers.Init();

            Loader.Initialized = true;

            EventsHandler.Init();
            Tests.Init();
        }
示例#14
0
 private void Awake()
 {
     _instance   = this;
     CharacterID = SystemInfo.deviceUniqueIdentifier;
 }
示例#15
0
 public DataLoader()
 {
     apiHandler  = new APIHandler();
     fileHandler = new FileHandler();
 }
示例#16
0
        public TrackingPageViewModel()
        {
            handler   = new APIHandler();
            stopwatch = new Stopwatch();
            stopwatch.Start();
            continueTimer = true;
            Distance      = 0;
            lastLoc       = null;

            Task.Factory.StartNew(async() =>
            {
                rideInfoId = await CreateRideInfoAsync();
            });

            StopTrackingCommand = new Command(async() =>
            {
                continueTimer = false;

                await App.Database.SaveRideInfoAsync(new RideInfo()
                {
                    ID = rideInfoId, AmountOfKm = Distance, ElapsedTime = ElapsedTime
                });

                await GetRideInfoAsync();

                //await SendTracks();

                //await NavigateToMainPage();

                await NavigateToTrackingSummaryPage();
            });

            Device.StartTimer(TimeSpan.FromMilliseconds(1000), () =>
            {
                Device.BeginInvokeOnMainThread(() =>
                {
                    ElapsedTime = stopwatch.Elapsed;
                });

                return(continueTimer);
            });

            List <Loc> locs = new List <Loc>();

            Device.StartTimer(TimeSpan.FromMilliseconds(500), () =>
            {
                Task.Factory.StartNew(async() =>
                {
                    var location = await MainThread.InvokeOnMainThreadAsync <Location>(this.GetLocation);
                    if (location != null)
                    {
                        Debug.WriteLine($"------- Speed: {location.Speed} Longitude: {location.Longitude}");
                        var loc = new Loc {
                            Longitude = location.Longitude, Latitude = location.Latitude, DateTimeOffset = location.Timestamp, RideInfoID = rideInfoId
                        };

                        if (location.Altitude != null)
                        {
                            loc.Altitude = (double)location.Altitude;
                        }
                        if (location.Accuracy != null)
                        {
                            loc.Accuracy = (double)location.Accuracy;
                        }

                        await App.Database.SaveLocationAsync(loc);

                        if (lastLoc != null)
                        {
                            Distance += Location.CalculateDistance(lastLoc.Latitude, lastLoc.Longitude, loc.Latitude, loc.Longitude, DistanceUnits.Kilometers);
                        }
                        lastLoc = loc;

                        //Console.WriteLine($"Accuracy: {location.Accuracy}, Time: {location.Timestamp}, Long: {location.Longitude}, lat: {location.Latitude}");
                    }
                    else
                    {
                        //await SendTracks();
                        await MainThread.InvokeOnMainThreadAsync(this.NavigateToMainPage);
                    }
                });

                return(continueTimer);
            });
        }
        private BaseDictionary[] InitialiseMetroNetwork()
        {
            StationDictionary stationDiction = new StationDictionary(APIHandler.GetStationList());
            LineDictionary    lineDiction    = new LineDictionary(APIHandler.GetLineList(), APIHandler.GetLineColors());

            MetroNetwork.Initialise(stationDiction, lineDiction);

            BaseDictionary[] dictionaries = new BaseDictionary[] { stationDiction, lineDiction };
            return(dictionaries);
        }
示例#18
0
 public APIHandler()
 {
     Instance = this;
 }
示例#19
0
 public void OnLoginClickEvent()
 {
     StartCoroutine(APIHandler.getAPIHandler().Login(usernameInput.text, passwordInput.text));
 }
示例#20
0
        public IActionResult Bar()
        {
            int         x          = 0;
            int         y          = 0;
            int         z          = 0;
            int         a          = 0;
            int         b          = 0;
            int         c          = 0;
            APIHandler  webHandler = new APIHandler();
            List <Drug> Drug1      = webHandler.GetObject1();

            foreach (Drug item in Drug1)
            {
                if (item.Cocaine == "Y")
                {
                    x = x + 1;
                }
                if (item.Ethanol == "Y")
                {
                    y = y + 1;
                }
                if (item.Amphet == "Y")
                {
                    z = z + 1;
                }
                if (item.FentanylAnalogue == "Y")
                {
                    a = a + 1;
                }
                if (item.Fentanyl == "Y")
                {
                    b = b + 1;
                }

                if (item.Tramad == "Y")
                {
                    c = c + 1;
                }
            }
            var lstmodel = new List <ReportViewModel>();

            lstmodel.Add(new ReportViewModel {
                DimensionOne = "Cocaine", Quantity = x
            });


            lstmodel.Add(new ReportViewModel {
                DimensionOne = "Ethanol", Quantity = y
            });
            lstmodel.Add(new ReportViewModel {
                DimensionOne = "Amphet", Quantity = z
            });
            lstmodel.Add(new ReportViewModel {
                DimensionOne = "Fentanyl", Quantity = b
            });
            lstmodel.Add(new ReportViewModel {
                DimensionOne = "Tramad", Quantity = c
            });
            lstmodel.Add(new ReportViewModel {
                DimensionOne = "FentanylAnalogue", Quantity = a
            });
            return(View(lstmodel));
        }
        public CollegeScorecardViewModel GetStudentBodyandCostData(int?id)
        {
            StudentBodyData           studentbodydata       = new StudentBodyData();
            StudentBody               studentbodyfromDB     = new StudentBody();
            CostAidEarningsData       costaidearningsdata   = new CostAidEarningsData();
            CostAidEarnings           costaidearningsfromDB = new CostAidEarnings();
            CollegeScorecardViewModel collegescorecarddata  = new CollegeScorecardViewModel();
            string studentbodyandcostdata = "";

            //Retrieving the list of colleges from Database
            List <School> schoolslist = dbContext.Schools.ToList();

            //Retrieving the studentbody data from Database for the selected college
            studentbodyfromDB = dbContext.StudentBody.Where(s => s.id == id).FirstOrDefault();
            //Retrieving the studentbody data from Database for the selected college
            costaidearningsfromDB = dbContext.CostAidEarnings.Where(s => s.id == id).FirstOrDefault();

            //check if the count is 0 (no data available in database), then call the API
            if (schoolslist.Count == 0)
            {
                Schools schoolsdata = GetSchoolsDatafromAPI();
                foreach (School school in schoolsdata.results)
                {
                    schoolslist.Add(school);
                }
            }

            //check if the studentbodyfromDB or costaidearningsfromDB is null (no data available in database), then call the API

            if (studentbodyfromDB == null || costaidearningsfromDB == null)
            {
                APIHandler webHandler = new APIHandler();
                studentbodyandcostdata = webHandler.GetStudentBodyandCostDataAPI(id);
                var settings = new JsonSerializerSettings
                {
                    NullValueHandling     = NullValueHandling.Include,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                if (!studentbodyandcostdata.Equals(""))
                {
                    // JsonConvert is part of the NewtonSoft.Json Nuget package
                    studentbodydata     = JsonConvert.DeserializeObject <StudentBodyData>(studentbodyandcostdata, settings);
                    costaidearningsdata = JsonConvert.DeserializeObject <CostAidEarningsData>(studentbodyandcostdata, settings);
                }

                foreach (StudentBody studentbody in studentbodydata.results)
                {
                    //Database will give PK constraint violation error when trying to insert record with existing PK.
                    //So add company only if it doesnt exist, check existence using symbol (PK)

                    if (dbContext.StudentBody.Where(c => c.id.Equals(studentbody.id)).Count() == 0)
                    {
                        dbContext.StudentBody.Add(studentbody);
                    }
                    collegescorecarddata.StudentBody = studentbody;
                }

                foreach (CostAidEarnings costaidearnings in costaidearningsdata.results)
                {
                    //Database will give PK constraint violation error when trying to insert record with existing PK.
                    //So add company only if it doesnt exist, check existence using symbol (PK)

                    if (dbContext.CostAidEarnings.Where(c => c.id.Equals(costaidearnings.id)).Count() == 0)
                    {
                        dbContext.CostAidEarnings.Add(costaidearnings);
                    }
                    collegescorecarddata.CostAidEarnings = costaidearnings;
                }

                dbContext.SaveChanges();
                collegescorecarddata.SchoolsList = schoolslist;
            }

            //check if the data in the DB is older than 30 days?, then call the API

            else if (studentbodyfromDB != null && costaidearningsfromDB != null)
            {
                // Checking the last saved data time for studentbody and costaidrearnings records
                int studentbodylastSaveddataTime     = (DateTime.Now.Date - studentbodyfromDB.CreatedOn.Date).Days;
                int costaidearningslastSaveddataTime = (DateTime.Now.Date - costaidearningsfromDB.CreatedOn.Date).Days;
                if (studentbodylastSaveddataTime > 30 || costaidearningslastSaveddataTime > 30)
                {
                    APIHandler webHandler = new APIHandler();
                    studentbodyandcostdata = webHandler.GetStudentBodyandCostDataAPI(id);
                    var settings = new JsonSerializerSettings
                    {
                        NullValueHandling     = NullValueHandling.Include,
                        MissingMemberHandling = MissingMemberHandling.Ignore
                    };

                    if (!studentbodyandcostdata.Equals(""))
                    {
                        // JsonConvert is part of the NewtonSoft.Json Nuget package
                        studentbodydata     = JsonConvert.DeserializeObject <StudentBodyData>(studentbodyandcostdata, settings);
                        costaidearningsdata = JsonConvert.DeserializeObject <CostAidEarningsData>(studentbodyandcostdata, settings);
                    }

                    foreach (StudentBody studentbody in studentbodydata.results)
                    {
                        //Database will give PK constraint violation error when trying to insert record with existing PK.
                        //So add company only if it doesnt exist, check existence using symbol (PK)

                        if (dbContext.StudentBody.Where(c => c.id.Equals(studentbody.id)).Count() == 0)
                        {
                            dbContext.StudentBody.Add(studentbody);
                        }

                        // Update the existing DB record with the latest data from API
                        else
                        {
                            studentbodyfromDB.CreatedOn = DateTime.Now;
                            studentbodyfromDB.latestadmissionsadmission_rateoverall     = studentbody.latestadmissionsadmission_rateoverall;
                            studentbodyfromDB.latestcompletioncompletion_rate_4yr_150nt = studentbody.latestcompletioncompletion_rate_4yr_150nt;
                            studentbodyfromDB.lateststudentdemographicsfemale_share     = studentbody.lateststudentdemographicsfemale_share;
                            studentbodyfromDB.lateststudentgrad_students   = studentbody.lateststudentgrad_students;
                            studentbodyfromDB.lateststudentpart_time_share = studentbody.lateststudentpart_time_share;
                            studentbodyfromDB.lateststudentretention_ratefour_yearfull_time = studentbody.lateststudentretention_ratefour_yearfull_time;
                            studentbodyfromDB.lateststudentsize      = studentbody.lateststudentsize;
                            dbContext.Entry(studentbodyfromDB).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
                        }
                        collegescorecarddata.StudentBody = studentbody;
                    }

                    foreach (CostAidEarnings costaidearnings in costaidearningsdata.results)
                    {
                        //Database will give PK constraint violation error when trying to insert record with existing PK.
                        //So add company only if it doesnt exist, check existence using symbol (PK)

                        if (dbContext.CostAidEarnings.Where(c => c.id.Equals(costaidearnings.id)).Count() == 0)
                        {
                            dbContext.CostAidEarnings.Add(costaidearnings);
                        }

                        // Update the existing DB record with the latest data from API
                        else
                        {
                            costaidearningsfromDB.CreatedOn = DateTime.Now;
                            costaidearningsfromDB.latestaidfederal_loan_rate            = costaidearnings.latestaidfederal_loan_rate;
                            costaidearningsfromDB.latestaidmedian_debtcompletersoverall = costaidearnings.latestaidmedian_debtcompletersoverall;
                            costaidearningsfromDB.latestaidpell_grant_rate               = costaidearnings.latestaidpell_grant_rate;
                            costaidearningsfromDB.latestcostavg_net_pricepublic          = costaidearnings.latestcostavg_net_pricepublic;
                            costaidearningsfromDB.latestcosttuitionin_state              = costaidearnings.latestcosttuitionin_state;
                            costaidearningsfromDB.latestcosttuitionout_of_state          = costaidearnings.latestcosttuitionout_of_state;
                            costaidearningsfromDB.latestearnings10_yrs_after_entrymedian = costaidearnings.latestearnings10_yrs_after_entrymedian;
                        }
                        collegescorecarddata.CostAidEarnings = costaidearnings;
                    }

                    dbContext.SaveChanges();
                    collegescorecarddata.SchoolsList = schoolslist;
                }

                else
                {
                    collegescorecarddata.SchoolsList     = schoolslist;
                    collegescorecarddata.StudentBody     = studentbodyfromDB;
                    collegescorecarddata.CostAidEarnings = costaidearningsfromDB;
                }
            }
            return(collegescorecarddata);
        }
示例#22
0
 public void UpdateHomeworkStatus(bool newStatus)
 {
     this.hasCompleted = newStatus;
     APIHandler.UpdateHomeworkStatus(this);
 }
示例#23
0
        private async Task <DialogTurnResult> EndProcessingIntents(WaterfallStepContext stepContext, CancellationToken cancellationToken)
        {
            var authenticatedUserIsAuthenticated = await _AuthenticatedUserAccessor.GetAsync(stepContext.Context, () => new AuthenticatedUser());

            // var apiResults = await _AuthenticatedUserAccessor.GetAsync(stepContext.Context, () => new APIResults());

            if (stepContext.Result == null || stepContext.Result.GetType() != typeof(Intent))
            {
                return(await stepContext.EndDialogAsync());
            }

            Intent executingIntent = (Intent)stepContext.Result;

            // now call graph API
            // bur check if token expired
            if (authenticatedUserIsAuthenticated.IsAuthenticated /*&& authenticatedUserIsAuthenticated.Expiration > DateTime.UtcNow*/)
            {
                executingIntent.Offset = stepContext.Context.Activity.LocalTimestamp.Value.Offset;
                Type       T          = System.Reflection.Assembly.GetExecutingAssembly().GetType(executingIntent.APIEndpointHandler);
                APIHandler apiHandler = Activator.CreateInstance(T, new object[] { authenticatedUserIsAuthenticated.JwtSecurityToken }) as APIHandler;
                APIResult  result     = await apiHandler.ExecuteAPI(executingIntent);

                // await stepContext.Context.SendActivityAsync(MessageFactory.Text(string.Format(executingIntent.ConfirmationText, executingIntent.RequiredEntities.Select(entity => entity.Value).ToArray())), cancellationToken);

                if (result.Code == APIResultCode.Ok)
                {
                    if (authenticatedUserIsAuthenticated.APIResults == null)
                    {
                        authenticatedUserIsAuthenticated.APIResults = new APIResults();
                    }

                    authenticatedUserIsAuthenticated.APIResults.Add(result);

                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(result.ResultText), cancellationToken);
                }
                else
                {
                    await stepContext.Context.SendActivityAsync(MessageFactory.Text(result.ErrorText), cancellationToken);

                    //Logger.LogInformation(result.ErrorText);
                }

                await stepContext.Context.SendActivityAsync(MessageFactory.Text("You can make your other request"), cancellationToken);
            }
            else
            {
                // log in again

                authenticatedUserIsAuthenticated.IsAuthenticated = false;

                await _AuthenticatedUserAccessor.SetAsync(stepContext.Context, authenticatedUserIsAuthenticated, cancellationToken);

                await stepContext.Context.SendActivityAsync(MessageFactory.Text($"Session expired. Please, login again."), cancellationToken);

                await stepContext.EndDialogAsync();

                return(await stepContext.BeginDialogAsync(this.InitialDialogId));

                // return await PromptStepAsync(stepContext, cancellationToken);
            }

            return(await stepContext.EndDialogAsync());
        }
示例#24
0
        private async void refreshLabel(String toSymbol, Double quantity)
        {
            Double convertedQuantity = await APIHandler.ConvertWithoutSaving(toSymbol, Wallet, quantity);

            FinalQTD.Text = convertedQuantity.ToString() + " " + toSymbol;
        }
示例#25
0
        public void GetLineColorsTest()
        {
            var colors = APIHandler.GetLineColors();

            Assert.IsNotNull(colors); // this method can only be fully tested visually in display of map
        }
示例#26
0
 protected void btnPopupEditar_Click(object sender, EventArgs e)
 {
     APIHandler.createFile(editArchivo.Text, editContent.Text);
 }
示例#27
0
 public MediaOperations(APIHandler APIHandler)
 {
     this.APIHandler = APIHandler;
 }
示例#28
0
        public IActionResult CollegeScorecard(int? id)
        {
            
            if (id == null)
            {
                ViewBag.collegeselected = 0;
                CollegeScorecardViewModel collegescorecarddata = new CollegeScorecardViewModel();

                List<School> schoolslist = dbContext.Schools.ToList();

                //check if the count is 0 (no data available in database), then call the API
                if(schoolslist.Count == 0)
                {
                    APIHandler webHandler = new APIHandler();
                    Schools schoolsdata = webHandler.GetSchoolsData();
                    foreach (School school in schoolsdata.results)
                    {
                        schoolslist.Add(school);
                    }
                    collegescorecarddata.SchoolsList = schoolslist;
                }
                else
                {
                    collegescorecarddata.SchoolsList = schoolslist;
                }                
                
                return View(collegescorecarddata);
            }

            else
            {
                ViewBag.collegeselected = id;
                APIHandler webHandler = new APIHandler();
                string studentbodyandcostdata = webHandler.GetStudentBodyandCostData(id);
                
                StudentBodyData studentbodydata = new StudentBodyData();
                CostAidEarningsData costaidearningsdata = new CostAidEarningsData();
                CollegeScorecardViewModel collegescorecarddata = new CollegeScorecardViewModel();

                List<School> schoolslist = dbContext.Schools.ToList();

                /*check if the count is 0 (no data available in database), then call the API
                 * move to a different function
                if (schoolslist.Count == 0)
                {
                    APIHandler webHandler = new APIHandler();
                    Schools schoolsdata = webHandler.GetSchoolsData();
                    foreach (School school in schoolsdata.results)
                    {
                        schoolslist.Add(school);
                    }
                    collegescorecarddata.SchoolsList = schoolslist;
                }
                else
                {
                    collegescorecarddata.SchoolsList = schoolslist;
                }
                */

                collegescorecarddata.SchoolsList = schoolslist;

                var settings = new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    MissingMemberHandling = MissingMemberHandling.Ignore
                };

                if (!studentbodyandcostdata.Equals(""))
                {
                    // JsonConvert is part of the NewtonSoft.Json Nuget package
                    studentbodydata = JsonConvert.DeserializeObject<StudentBodyData>(studentbodyandcostdata, settings);
                    costaidearningsdata = JsonConvert.DeserializeObject<CostAidEarningsData>(studentbodyandcostdata, settings);                  

                }

                foreach (StudentBody studentbody in studentbodydata.results)
                {
                    //Database will give PK constraint violation error when trying to insert record with existing PK.
                    //So add company only if it doesnt exist, check existence using symbol (PK)
                    
                    if (dbContext.StudentBody.Where(c => c.id.Equals(studentbody.id)).Count() == 0)
                    {
                        dbContext.StudentBody.Add(studentbody);                        
                    }
                                       
                    collegescorecarddata.StudentBody = studentbody;
                }

                foreach (CostAidEarnings costaidearnings in costaidearningsdata.results)
                {
                    //Database will give PK constraint violation error when trying to insert record with existing PK.
                    //So add company only if it doesnt exist, check existence using symbol (PK)

                    if (dbContext.CostAidEarnings.Where(c => c.id.Equals(costaidearnings.id)).Count() == 0)
                    {
                        dbContext.CostAidEarnings.Add(costaidearnings);
                    }

                    collegescorecarddata.CostAidEarnings = costaidearnings;
                }

                dbContext.SaveChanges();
                                
                return View(collegescorecarddata);
            }

            
        }
示例#29
0
        /// <summary>
        /// Method that updates a user in the system via the API
        /// </summary>
        /// <returns></returns>
        public async Task PutUser()
        {
            await APIHandler <Salary> .PutOne($"Salaries/UpdateSalary/{BeforeEdit.Id}", SalaryAfter);

            await APIHandler <User> .PutOne($"Users/UpdateUser/{BeforeEdit.Id}", AfterEdit);
        }
示例#30
0
 public UsersOperations(APIHandler APIHandler)
 {
     this.APIHandler = APIHandler;
 }