Example #1
0
        private async void Login()
        {
            ApplicationVM appvm = App.Current.MainWindow.DataContext as ApplicationVM;
            string        json  = JsonConvert.SerializeObject(new SalesAuth()
            {
                OrganisationID   = CurrentOrganisation.ID,
                OrganisationName = CurrentOrganisation.OrganisationName,
                EmployeeName     = Username
            });

            using (HttpClient Organisation = new HttpClient())
            {
                HttpResponseMessage response = await Organisation.PostAsync("http://localhost:46080/api/Organisation/AuthSales", new StringContent(json, Encoding.UTF8, "application/json"));

                if (response.IsSuccessStatusCode)
                {
                    string jsonresponse = await response.Content.ReadAsStringAsync();

                    SalesAuth result = JsonConvert.DeserializeObject <SalesAuth>(jsonresponse);

                    if (result.Authorized == true)
                    {
                        ApplicationVM.auth  = result;
                        ApplicationVM.token = GetToken(result.OrganisationID, result.EmployeeName);
                        appvm.Login();
                    }
                    else
                    {
                        CardReaderTimer.Start();
                        Error = "No employee '" + result.EmployeeName + "' was found for organisation '" + result.OrganisationName + "'.";
                    }
                }
            }
        }
Example #2
0
        public void Logout()
        {
            while (Pages.Count > 0)
            {
                Pages.RemoveAt(Pages.Count - 1);
            }

            Pages.Add(new LoginVM());
            AppTitle    = "Cashless Payment Register";
            CurrentPage = Pages[0];
            auth        = null;
        }
Example #3
0
        public SalesAuth AuthSales([FromBody] SalesAuth data)
        {
            try
            {
                Organisation org      = OrganisationDA.GetOrganisation(data.OrganisationID);
                Employee     employee = EmployeeDA.GetEmployeeByName(data.EmployeeName, org);

                if (employee != null)
                {
                    data.Authorized = true;
                    data.EmployeeID = employee.ID;
                }

                return(data);
            }
            catch (Exception)
            {
                return(null);
            }

            return(new SalesAuth());
        }