public async void Register(UtsData data)
        {
            string json = JsonConvert.SerializeObject(data);
   
            Log.Info("Register", json);

           // Request Address of the API    
            string url = Server.url + "api/student/register";

           String result = null;
        
               using (WebClient wc = new WebClient())
               {
                
                wc.Headers[HttpRequestHeader.ContentType] = "application/json; charset=utf-8";
                wc.Headers.Add("AppKey", "66666");


                result = await wc.UploadStringTaskAsync(new Uri(url), json);
                   

                Log.Info("Register SUCCESS", result);
                HomeController loginController = new HomeController();
                await loginController.login(data.StudentId);

            }

              

        }
Exemplo n.º 2
0
        private bool studentIdFoundInUTSDatabase(string studentID, string password)
        {
            studentDataAtUTS = null;

            var assembly = typeof(LogOnActivity).GetTypeInfo().Assembly;
            Stream stream = assembly.GetManifestResourceStream("HELPS.utsData.csv");

            using (TextReader reader = new StreamReader(stream))
            {

                CsvReader csv = new CsvReader(reader);
                csv.Configuration.HasHeaderRecord = false;

                List<UtsData> records = csv.GetRecords<UtsData>().ToList();

                // Searches for the Student Details.
                foreach (UtsData data in records)
                {
                    //Checking only student id but not password for sake for login feature demonstration purpose only .
                    //Originally password MUST be checked as well.
                    if (data.StudentId.Trim().Equals(studentID.Trim()))
                    {
                        studentDataAtUTS = data;
                        return true;
                    }
                }
            }
            return false;
        }