예제 #1
0
        public async Task <bool> CheckLogin()
        {
            try
            {
                var username = Preferences.Get(AuthorizeConstants.UserKey, string.Empty);
                var password = Preferences.Get(AuthorizeConstants.PasswordKey, string.Empty);

                var response = await JongSnamServices.LoginWithHttpMessagesAsync(username, password);

                var userModel = await GetRespondDtoHandlerHttpStatus <UserModel>(response);

                if (userModel == null)
                {
                    return(false);
                }
                else
                {
                    Preferences.Clear();

                    // save access token
                    Preferences.Set(AuthorizeConstants.UserIdKey, userModel.Id.ToString());
                    Preferences.Set(AuthorizeConstants.UserKey, userModel.Email);
                    Preferences.Set(AuthorizeConstants.PasswordKey, userModel.Password);
                    Preferences.Set(AuthorizeConstants.UserTypeKey, userModel.UserType);
                    Preferences.Set(AuthorizeConstants.IsLoggedInKey, userModel.IsLoggedIn.ToString());
                    await Task.Delay(MillisecondsDelay);
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #2
0
        public async Task <IEnumerable <PaymentDto> > GetPaymentByReservationId(int reservationId)
        {
            var response = await JongSnamServices.GetPaymentByReservationIdWithHttpMessagesAsync(reservationId, CustomHeaders);

            var respondModel = await GetRespondDtoHandlerHttpStatus <IEnumerable <PaymentDto> >(response);

            return(respondModel);
        }
        public async Task <IEnumerable <ReservationDto> > GetReservationBySearch(int userId, int startTimeYear, int startTimeMonth, int startTimeDay, int startTimeHour, int startTimeMinute, int startTimeSecond, int stopTimeYear, int stopTimeMonth, int stopTimeDay, int stopTimeHour, int stopTimeMinute, int stopTimeSecond, string userName, string storeName, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GetReservationBySearchWithHttpMessagesAsync(userId, startTimeYear, startTimeMonth, startTimeDay, startTimeHour, startTimeMinute, startTimeSecond, stopTimeYear, stopTimeMonth, stopTimeDay, stopTimeHour, stopTimeMinute, stopTimeSecond, userName, storeName, currentPage, pageSize, CustomHeaders);

            var ReservationDto = await GetRespondDtoHandlerHttpStatus <ReservationDtoBasePagingDto>(response);

            return(ReservationDto.Collection);
        }
        public async Task <IEnumerable <SubDistrictModel> > GetSubDistrictByDistrictId(int DistrictId)
        {
            var response = await JongSnamServices.GetSubDistrictByDistrictIdWithHttpMessagesAsync(DistrictId);

            var respondModel = await GetRespondDtoHandlerHttpStatus <IEnumerable <SubDistrictModel> >(response);

            return(respondModel);
        }
        public async Task <IEnumerable <ProvinceModel> > GetProvinces()
        {
            var response = await JongSnamServices.GetProvincesWithHttpMessagesAsync(CustomHeaders);

            var respondModel = await GetRespondDtoHandlerHttpStatus <IEnumerable <ProvinceModel> >(response);

            return(respondModel);
        }
        public async Task <List <EnumDto> > GetSubDistrict(int districtId)
        {
            var response = await JongSnamServices.GetEnumsWithHttpMessagesAsync("SubDistrict", districtId, CustomHeaders);

            var respondModel = await GetRespondDtoHandlerHttpStatus <List <EnumDto> >(response);

            return(respondModel);
        }
        public async Task <List <EnumDto> > GetProvinces()
        {
            var response = await JongSnamServices.GetEnumsWithHttpMessagesAsync("Province", null, CustomHeaders);

            var respondModel = await GetRespondDtoHandlerHttpStatus <List <EnumDto> >(response);

            return(respondModel);
        }
        public async Task <ReservationDetailDto> GetShowDetailYourReservation(int id)
        {
            var response = await JongSnamServices.GetShowDetailYourReservationWithHttpMessagesAsync(id, CustomHeaders);

            var ReservationDto = await GetRespondDtoHandlerHttpStatus <ReservationDetailDto>(response);

            return(ReservationDto);
        }
        public async Task <IEnumerable <FieldDto> > GetFieldByStoreId(int id, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GetFieldByStoreWithHttpMessagesAsync(id, currentPage, pageSize, CustomHeaders);

            var ReservationDto = await GetRespondDtoHandlerHttpStatus <FieldDtoBasePagingDto>(response);

            return(ReservationDto.Collection);
        }
        public async Task <IEnumerable <FieldDto> > GetFieldBySearch(double?startPrice, double?toPrice, int?districtId, int?provinceId, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GetFieldBySearchWithHttpMessagesAsync(startPrice, toPrice, districtId, provinceId, currentPage, pageSize, CustomHeaders);

            var ReservationDto = await GetRespondDtoHandlerHttpStatus <FieldDtoBasePagingDto>(response);

            return(ReservationDto.Collection);
        }
        public async Task <IEnumerable <GrahpDto> > GraphMonthReservation(int userId, int month, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GraphMonthReservationWithHttpMessagesAsync(userId, month, currentPage, pageSize, CustomHeaders);

            var ReservationDto = await GetRespondDtoHandlerHttpStatus <GrahpDtoBasePagingDto>(response);

            return(ReservationDto.Collection);
        }
        public async Task <IEnumerable <YourStore> > GetYourStores(int ownerId, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GetYourStoresWithHttpMessagesAsync(ownerId, currentPage, pageSize, CustomHeaders);

            var respondModel = await GetRespondDtoHandlerHttpStatus <YourStoreBasePagingDto>(response);

            return(respondModel.Collection);
        }
        public async Task <bool> AddStore(StoreRequest storeRequest)
        {
            try
            {
                var response = await JongSnamServices.AddStoreWithHttpMessagesAsync(storeRequest, CustomHeaders);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> ChangePassword(int id, ChangePasswordRequest changePasswordRequest)
        {
            try
            {
                var response = await JongSnamServices.ChangePasswordWithHttpMessagesAsync(id, changePasswordRequest);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> CreateUser(UserRequest userRequest)
        {
            try
            {
                var response = await JongSnamServices.CreateUserWithHttpMessagesAsync(userRequest);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> UpdateUser(int id, UpdateUserRequest updateUserRequest)
        {
            try
            {
                var response = await JongSnamServices.UpdateUserWithHttpMessagesAsync(id, updateUserRequest, CustomHeaders);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> DeleteReservation(int id)
        {
            try
            {
                var response = await JongSnamServices.DeleteReservationWithHttpMessagesAsync(id, CustomHeaders);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> CreateReservation(ReservationRequest reservationRequest)
        {
            try
            {
                var response = await JongSnamServices.CreateReservationWithHttpMessagesAsync(reservationRequest, CustomHeaders);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
        public async Task <bool> UpdateApprovalStatus(int id, ReservationApprovalRequest reservationApprovalRequest)
        {
            try
            {
                var response = await JongSnamServices.UpdateApprovalStatusWithHttpMessagesAsync(id, reservationApprovalRequest, CustomHeaders);

                return(true);
            }
            catch (Exception ex)
            {
                return(false);

                throw ex;
            }
        }
예제 #20
0
        public async Task <bool> Logut()
        {
            try
            {
                var id       = Preferences.Get(AuthorizeConstants.UserIdKey, string.Empty);
                var response = await JongSnamServices.LogoutWithHttpMessagesAsync(Convert.ToInt32(id));

                // remove
                Preferences.Clear();


                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #21
0
        public BaseServices()
        {
            ConfigurationService = DependencyService.Get <IConfigurationService>();
            ConnectivityService  = DependencyService.Get <IConnectivityService>();
            var handler = new HttpClientHandler();

            handler.ServerCertificateCustomValidationCallback = (msg, cert, chain, errors) =>
            {
                if (cert.Issuer.Equals("CN=localhost"))
                {
                    return(true);
                }
                return(errors == System.Net.Security.SslPolicyErrors.None);
            };
            //JongSnamServices = new JongSnamServices(new Uri("http://192.168.1.13:8588/"), handler);
            //JongSnamServices = new JongSnamServices(new Uri("http://172.18.52.145:8080/"), handler);
            JongSnamServices = new JongSnamServices(new Uri("https://jongsnamservices25640404210358.azurewebsites.net/"), handler);
        }
        public async Task GetUserById(int id, Action <UserDto> executeSuccess = null, Action <string, Exception> executeError = null)
        {
            try
            {
                var result = await InvokeServiceCheckInternetConnection(async() =>
                {
                    var response = await JongSnamServices.GetUserByIdWithHttpMessagesAsync(id, CustomHeaders);
                    return(await GetRespondDtoHandlerHttpStatus <UserDto>(response));
                });

                executeSuccess?.Invoke(result);
            }
            catch (InvalidAccessTokenException ex)
            {
                executeError?.Invoke(ex.Message, ex);
            }
            catch (BadRequestException ex)
            {
                executeError?.Invoke(MessageConstants.SomeValueINvalid + "\n[" + ex.Message + "]", ex);
            }
            catch (UnauthorizedException uex)
            {
                executeError?.Invoke(MessageConstants.UnauthorizedError, uex);
            }
            catch (InternalServerErrorException inex)
            {
                executeError?.Invoke(MessageConstants.SomethingWentWrong, inex);
            }
            catch (NoInternetConnectionException nicex)
            {
                executeError?.Invoke(MessageConstants.CannotConnectToInternet, nicex);
            }
            catch (Exception ex)
            {
                executeError?.Invoke(MessageConstants.SomethingWentWrong, ex);
            }
        }
        public async Task <IEnumerable <UserDto> > GetUsers()
        {
            var response = await JongSnamServices.GetUsersWithHttpMessagesAsync(CustomHeaders);

            return(await GetRespondDtoHandlerHttpStatus <IEnumerable <UserDto> >(response));
        }
예제 #24
0
        public async Task <SumaryRatingDto> GetReviewByStoreId(int storeId, int currentPage, int pageSize)
        {
            var response = await JongSnamServices.GetReviewByStoreIdWithHttpMessagesAsync(storeId, currentPage, pageSize, CustomHeaders);

            return(await GetRespondDtoHandlerHttpStatus <SumaryRatingDto>(response));
        }
        public async Task <SubDistrictModel> GetSubDistrictById(int id)
        {
            var response = await JongSnamServices.GetSubDistrictByIdWithHttpMessagesAsync(id, CustomHeaders);

            return(await GetRespondDtoHandlerHttpStatus <SubDistrictModel>(response));
        }
        public async Task <StoreDetailDto> GetStoreById(int id)
        {
            var response = await JongSnamServices.GetStoreByIdWithHttpMessagesAsync(id, CustomHeaders);

            return(await GetRespondDtoHandlerHttpStatus <StoreDetailDto>(response));
        }