Exemplo n.º 1
0
        public void AllRestsTest()
        {
            var service = new RestServices(MockRepo.Object);

            service.AllRests();
            MockRepo.Verify(m => m.GetAllRestaurants(), Times.Once);
        }
Exemplo n.º 2
0
        public void SortRestaurantsTest()
        {
            var service   = new RestServices(MockRepo.Object);
            var checkList = service.SortRestaurants("name");

            CollectionAssert.AreEqual(checkList, MockRepo.Object.GetAllRestaurants().OrderBy(x => x.restName).ToList());
        }
Exemplo n.º 3
0
        private async void LoginAction(object obj)
        {
            try
            {
                if (IsBusy)
                {
                    return;
                }
                IsBusy = true;
                using (var res = new RestServices())
                {
                    var result = await res.Post <AuthenticationToken>("Account/Login", Model);

                    if (result != null && result.roles != null && result.roles.Where(O => O.ToUpper() == "PEMOHON").FirstOrDefault() != null)
                    {
                        var app = await Helper.GetBaseApp();

                        app.SetToken(result);
                        app.ChangeScreen(new MainPage());
                    }
                    else
                    {
                        throw new SystemException("Anda Tidak Memiliki Akses");
                    }
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
            }
            finally
            {
                IsBusy = false;
            }
        }
        public async Task <IEnumerable <permohonan> > GetPermohonans()
        {
            try
            {
                if (!isInstance)
                {
                    isInstance = true;
                    list       = new List <permohonan>();
                    using (var rest = new RestServices())
                    {
                        var result = await rest.Get <List <permohonan> >("api/ClientPermohonan");

                        if (result != null)
                        {
                            foreach (var item in result)
                            {
                                list.Add(item);
                            }
                        }
                    }
                }

                return(list);
            }
            catch (Exception ex)
            {
                throw new SystemException(ex.Message);
            }
        }
        public async Task <bool> CreateNewPermohonan(permohonan item)
        {
            try
            {
                using (var rest = new RestServices())
                {
                    var result = await rest.Post <permohonan>("api/ClientPermohonan", item);

                    if (result != null)
                    {
                        lastPermohonan = result;
                        if (list == null)
                        {
                            list = new List <permohonan>();
                        }

                        list.Add(lastPermohonan);
                        return(true);
                    }
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new SystemException(ex.Message);
            }
        }
Exemplo n.º 6
0
        protected async override Task OnSaveAsync(MouseEventArgs e)
        {
            try
            {
                DetailsViewModel     dvm     = Model as DetailsViewModel;
                AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject;
                authObj.Validate(true);
                authObj.GetValidationErrors().AbortIfHasErrors();
                var user = await RestServices.Authenticate(dvm.ServiceProvider,
                                                           authObj.EmailProperty.Value, authObj.PasswordProperty.Value);

                if (authStateProvider is AuthStateProvider asp)
                {
                    asp.SetCurrentPrincipal(user);
                }

                if (QueryHelpers.ParseQuery(new Uri(Navigation.Uri).Query).TryGetValue("redirectUri", out var param))
                {
                    Navigation.NavigateTo(param.First());
                }
                else
                {
                    Navigation.NavigateTo("/");
                }
            }
            catch (Exception ex)
            {
                Model.Errors = Model.ErrorParser.FromException(ex);
            }
        }
Exemplo n.º 7
0
        protected async Task <ClaimsPrincipal> Authenticate()
        {
            DetailsViewModel     dvm     = Model as DetailsViewModel;
            AuthenticationObject authObj = dvm.DetailsObject as AuthenticationObject;

#if REST
            authObj.Validate(true);
            authObj.GetValidationErrors().AbortIfHasErrors();
            return(await RestServices.Authenticate(App.Services,
                                                   authObj.EmailProperty.Value, authObj.PasswordProperty.Value));
#endif
#if WCF
            authObj.Validate(true);
            authObj.GetValidationErrors().AbortIfHasErrors();
            var principal = WcfServices.Authenticate(authObj.EmailProperty.Value, authObj.PasswordProperty.Value);
            return(await Task.FromResult(principal));
#endif
#if TWO_TIER
            await dvm.SaveAsync();

            dvm.Errors.AbortIfHasErrors();

            PersonInfo userInfo = null;
            using (var s = dvm.ServiceProvider.CreateScope())
            {
                IPersonService personService = s.ServiceProvider.GetRequiredService <IPersonService>();
                userInfo = (await personService.ReadAsync(authObj.EmailProperty.Value)).Result;
            }
            ClaimsIdentity ci = SecurityManager.CreateIdentity("Password", userInfo);
            return(new ClaimsPrincipal(ci));
#endif
        }
Exemplo n.º 8
0
        public void TopThreeRestsTest() //rewrite verification for this test later
        {
            var service = new RestServices(MockRepo.Object);

            service.TopThreeRests();
            MockRepo.Verify(m => m.GetAllRestaurants(), Times.Once);
        }
Exemplo n.º 9
0
        public void AddRestTest()
        {
            var        service    = new RestServices(MockRepo.Object);
            Restaurant testaurant = new Restaurant(); testaurant.ID = 0; testaurant.restName = "fakeRestName"; testaurant.city = "fakeCity"; testaurant.latitude = "fake"; testaurant.longitude = "fake"; testaurant.locality = "land o fakes"; testaurant.ID = 0; testaurant.restAddress = "fakeAddress"; testaurant.cuisines = "fakeCuisine"; testaurant.zipcode = "12345";

            service.AddRest(testaurant);
            MockRepo.Verify(m => m.AddRestaurant(It.IsAny <Restaurant>()), Times.Once);
        }
Exemplo n.º 10
0
        public async Task <IEnumerable <inbox> > GetItemsAsync(int id)
        {
            using (var res = new RestServices())
            {
                list = await res.Get <List <inbox> >("api/inbox?id=" + id);

                return(list.OrderByDescending(O => O.Tanggal));
            }
        }
Exemplo n.º 11
0
 public frmSeleccionPago(DatosPago datosPago, LogicaForm logicaForm)
 {
     InitializeComponent();
     // TODO: Complete member initialization
     this.datosPago  = datosPago;
     srv             = new RestServices();
     this.logicaForm = logicaForm;
     SetDescripcion(this.datosPago);
 }
Exemplo n.º 12
0
        public void SearchAllTest()
        {
            var        service    = new RestServices(MockRepo.Object);
            Restaurant testaurant = new Restaurant(); testaurant.ID = 0; testaurant.restName = "fakeRestName"; testaurant.city = "fakeCity"; testaurant.latitude = "fake"; testaurant.longitude = "fake"; testaurant.locality = "land o fakes"; testaurant.ID = 0; testaurant.restAddress = "fakeAddress"; testaurant.cuisines = "fakeCuisine"; testaurant.zipcode = "12345";

            service.AddRest(testaurant);
            List <Restaurant> checkList = service.SearchAll("fakeRestName");

            CollectionAssert.AreEqual(checkList, MockRepo.Object.GetAllRestaurants().Where(x => Regex.IsMatch(x.restName, "fakeRestName")).ToList());
        }
Exemplo n.º 13
0
        static void Main(string[] args)
        {
            RestServices   service      = new RestServices();
            WebServiceHost _serviceHost = new WebServiceHost(service, new Uri("http://localhost:8000/BarcodeService"));

            _serviceHost.Open();
            Console.Write("服务端正在监听8000端口......");
            Console.ReadKey();
            _serviceHost.Close();
        }
Exemplo n.º 14
0
 public frmSeleccionBanco(DatosPago datosPago, LogicaForm logicaForm)
 {
     InitializeComponent();
     this.srv              = new RestServices();
     this.datosPago        = datosPago;
     this.bancos           = srv.GetBancos(this.datosPago.Tarjeta.id);
     cbBanco.DataSource    = bancos;
     cbBanco.DisplayMember = "name";
     this.logicaForm       = logicaForm;
     SetDescripcion(datosPago);
 }
        public void AddRevTest()
        {
            var        restService = new RestServices(MockRestRepo.Object);
            Restaurant testaurant  = new Restaurant(); testaurant.ID = 0; testaurant.restName = "fakeRestName"; testaurant.city = "fakeCity"; testaurant.latitude = "fake"; testaurant.longitude = "fake"; testaurant.locality = "land o fakes"; testaurant.ID = 0; testaurant.restAddress = "fakeAddress"; testaurant.cuisines = "fakeCuisine"; testaurant.zipcode = "12345";
            var        revService  = new RevServices(MockRevRepo.Object);
            Review     testReview  = new Review(); testReview.ID = 0; testReview.RestID = 0; testReview.rating = 3; testReview.reviewBody = "It's ok"; testReview.reviewer = "testReviewer";

            restService.AddRest(testaurant);
            revService.AddRev(testaurant, testReview);
            MockRevRepo.Verify(m => m.AddReview(It.IsAny <Restaurant>(), It.IsAny <Review>()), Times.Once);
        }
Exemplo n.º 16
0
        public void getAverageRatingTest()
        {
            var        service     = new RestServices(MockRepo.Object);
            Restaurant testaurant  = new Restaurant(); testaurant.ID = 0; testaurant.restName = "fakeRestName"; testaurant.city = "fakeCity"; testaurant.latitude = "fake"; testaurant.longitude = "fake"; testaurant.locality = "land o fakes"; testaurant.ID = 0; testaurant.restAddress = "fakeAddress"; testaurant.cuisines = "fakeCuisine"; testaurant.zipcode = "12345";
            Review     testReview1 = new Review(); testReview1.rating = 5; testReview1.RestID = testaurant.ID; testReview1.ID = 1; testReview1.reviewer = "john fakeman"; testReview1.reviewBody = "Real fake food!";
            Review     testReview2 = new Review(); testReview2.rating = 1; testReview2.RestID = testaurant.ID; testReview2.ID = 2; testReview2.reviewer = "jenny fakewoman"; testReview2.reviewBody = "Real awful fake food!";

            testaurant.Reviews.Add(testReview1);
            testaurant.Reviews.Add(testReview2);
            double testD = service.getAverageRating(testaurant);

            Assert.AreEqual(3.0, testD);
        }
Exemplo n.º 17
0
 public DetailsPageViewModel(INavigation navigation)
 {
     try
     {
         EmployeDetail = new ObservableCollection <Data>();
         RequestData   = new RestServices();
         conn          = new SQLConnection();
         RequestData.RetrieveData();
         var _userlist = conn.GetAllUsers();
         EmployeDetail = new ObservableCollection <Data>(_userlist);
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 18
0
        public frmSeleccionCuotas(DatosPago datosPago, LogicaForm logicaForm)
        {
            InitializeComponent();
            this.datosPago   = datosPago;
            this.srv         = new RestServices();
            datosPago.Cuotas = srv.GetCantidadCuotas(datosPago.Banco.id, datosPago.Monto, datosPago.Tarjeta.id);

            if (datosPago.Cuotas.Count > 0)
            {
                cbCuotas.DataSource    = datosPago.Cuotas[0].payer_costs;
                cbCuotas.DisplayMember = "installments";
            }
            this.logicaForm = logicaForm;
            SetDescripcion(datosPago);
        }
        public async Task <permohonan> GetPermohonanById(int id)
        {
            try
            {
                using (var rest = new RestServices())
                {
                    var result = await rest.Get <permohonan>("api/ClientPermohonan/" + id);

                    return(result);
                }
            }
            catch (Exception ex)
            {
                throw new SystemException(ex.Message);
            }
        }
Exemplo n.º 20
0
        protected override async void Invoke(ContentPage contentPage)
        {
            switch (NetworkService.ExistsInternetConnection())
            {
            case true:
                //await contentPage.DisplayAlert("Internet Connection", "You are connected", "OK");
                restServices = new RestServices();
                topHeadlines = await restServices.GetTopHeadlines();

                break;

            case false:
                await contentPage.DisplayAlert("Internet Connection", "You are NOT connected. Please, get a connection", "OK");

                break;
            }
        }
Exemplo n.º 21
0
        public async Task <IEnumerable <layanan> > GetItemsAsync(bool forceRefresh = false)
        {
            if (isInstance)
            {
                return(list);
            }
            else
            {
                isInstance = true;
                using (var res = new RestServices())
                {
                    list = await res.Get <List <layanan> >("api/layanan");

                    return(list);
                }
            }
        }
Exemplo n.º 22
0
        public async Task <IEnumerable <manifest> > GetItemsAsync(bool forceRefresh = false)
        {
            try
            {
                using (var res = new RestServices())
                {
                    IEnumerable <manifest> result = await res.Get <List <manifest> >("api/manifest/newmanifest");

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
                return(null);
            }
        }
Exemplo n.º 23
0
        public async Task <stt> FindSTT(string stt)
        {
            try
            {
                using (var res = new RestServices())
                {
                    var result = await res.Get <stt>(string.Format("api/manifest/FindBySTT?stt={0}", stt));

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
                return(null);
            }
        }
Exemplo n.º 24
0
        public async Task <stt> FindSTT(int agentId, string stt)
        {
            try
            {
                using (var res = new RestServices())
                {
                    var result = await res.Get <List <stt> >(string.Format("api/manifest/find?id={0}&stt={1}", agentId, stt));

                    return(result.FirstOrDefault());
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
                return(null);
            }
        }
Exemplo n.º 25
0
        public async Task <manifest> GetItemAsync(string id)
        {
            try
            {
                using (var res = new RestServices())
                {
                    var result = await res.Get <manifest>(string.Format("api/manifest/{0}", id));

                    return(result);
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
                return(null);
            }
        }
Exemplo n.º 26
0
        public async Task <List <OwnerPets> > GetData()
        {
            try
            {
                var httpClient        = new RestServices <List <OwnerPets> >();
                List <OwnerPets> list = await httpClient.GetAllAsync();

                if (list == null || list.Count == 0)
                {
                    return(null);
                }

                return(list);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 27
0
        public async Task <AuthenticationToken> Login(string user, string password)
        {
            using (var res = new RestServices())
            {
                try
                {
                    var result = await res.GenerateTokenAsync(user, password);

                    if (res != null)
                    {
                        return(result);
                    }
                    throw new SystemException("Anda Tidak Memiliki AKses");
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }
Exemplo n.º 28
0
        public async Task <bool> UpdateItemAsync(manifest item)
        {
            try
            {
                using (var res = new RestServices())
                {
                    item.RecieveOnPort = DateTime.Now;
                    var result = await res.Put <manifest>("api/manifest/" + item.Id, item);

                    if (result != null)
                    {
                        return(true);
                    }
                    throw new SystemException("data tidak tersimpan");
                }
            }
            catch (Exception ex)
            {
                Helper.ShowMessageError(ex.Message);
                return(false);
            }
        }
Exemplo n.º 29
0
        public MainPageViewModel()
        {
            TypeCommand         = new Command(IncreaseCount);
            NewsArticlesCommand = new Command(GetTopHeadlines);
            restServices        = new RestServices();
            permissionService   = new PermissionService();
            //be sure to unsubscribe from this event when finished
            //ConnectionBoxViewVariables("White", "Red", false, "Internet Connection Lost");
            Connectivity.ConnectivityChanged += Connectivity_ConnectivityChanged;

            if (NetworkService.ExistsInternetConnection())
            {
                OnPropertyChanged(nameof(IsRefreshing));
                //GetTopHeadlines();
            }
            else
            {
                //internet connection does not exist
                connectionState = "DISCONNECTED";
                ConnectionBoxViewVariables("White", "Red", true, "Internet Connection Lost");
            }
        }
Exemplo n.º 30
0
        public async Task <bool> AddItemAsync(inbox item)
        {
            using (var res = new RestServices())
            {
                try
                {
                    item.Tanggal = DateTime.Now;
                    var result = await res.Post <inbox>("api/inbox", item);

                    if (res != null)
                    {
                        list.Add(result);
                        return(true);
                    }
                    return(false);
                }
                catch (Exception ex)
                {
                    throw new SystemException(ex.Message);
                }
            }
        }