public PhoneNoCountryCodePage()
 {
     InitializeComponent();
     _objCountryListResponse = new CountryListResponse();
     _apiServices            = new RestApi();
     _baseUrl = Domain.GetCountryApiConstant;
 }
        public UserRegistrationPage()
        {
            InitializeComponent();
            NavigationPage.SetHasNavigationBar(this, false);
            // ImageCtryFlage.Source = "https://restcountries.eu/data/aut.svg";
            _objCountryListResponse      = new CountryListResponse();
            _objUserRegistrationResponse = new UserRegistrationResponse();
            _objUserRegistrationRequest  = new UserRegistrationRequest();
            BindingContext       = _objUserRegistrationRequest;
            _apiServices         = new RestApi();
            _baseUrl             = Domain.GetCountryApiConstant;
            _baseUrlSubmitRecord = Settings.Url + Domain.UserSignUpApiConstant;

            LoadCountryData();

            Device.BeginInvokeOnMainThread(() => {
                Device.StartTimer(TimeSpan.FromSeconds(1), () =>
                {
                    if (Settings.CountryCode > 0)
                    {
                        ImageCtryFlage.Source = Settings.CountryFlag;
                    }
                    return(true);
                });
                //if (Settings.CountryCode > 0)
                //{
                //    ImageCtryFlage.Source = Settings.CountryFlag;
                //}
            });
        }
Esempio n. 3
0
        public CountryListResponse GetCountriesNewerThen(int companyId, DateTime?lastUpdateTime)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                if (lastUpdateTime != null)
                {
                    response.Countries = unitOfWork.GetCountryRepository()
                                         .GetCountriesNewerThen(companyId, (DateTime)lastUpdateTime)
                                         .ConvertToCountryViewModelList();
                }
                else
                {
                    response.Countries = unitOfWork.GetCountryRepository()
                                         .GetCountries(companyId)
                                         .ConvertToCountryViewModelList();
                }
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Countries = new List <CountryViewModel>();
                response.Success   = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Esempio n. 4
0
        public CountryListResponse Sync(SyncCountryRequest request)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response.Countries = new List <CountryViewModel>();

                if (request.LastUpdatedAt != null)
                {
                    response.Countries.AddRange(unitOfWork.GetCountryRepository()
                                                .GetCountriesNewerThen(request.CompanyId, (DateTime)request.LastUpdatedAt)
                                                ?.ConvertToCountryViewModelList() ?? new List <CountryViewModel>());
                }
                else
                {
                    response.Countries.AddRange(unitOfWork.GetCountryRepository()
                                                .GetCountries(request.CompanyId)
                                                ?.ConvertToCountryViewModelList() ?? new List <CountryViewModel>());
                }

                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Countries = new List <CountryViewModel>();
                response.Success   = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
        public CountryListResponse Sync(SyncCountryRequest request)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response = WpfApiHandler.SendToApi <SyncCountryRequest, CountryViewModel, CountryListResponse>(request, "Sync");
            }
            catch (Exception ex)
            {
                response.Countries = new List <CountryViewModel>();
                response.Success   = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Esempio n. 6
0
        public CountryListResponse GetCountriesForPopup(int companyId, string filterString)
        {
            CountryListResponse     response  = new CountryListResponse();
            List <CountryViewModel> countries = new List <CountryViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM Countries " +
                        "WHERE (@Name IS NULL OR @Name = '' OR Name LIKE @Name OR Code LIKE @Name) " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced, Id DESC " +
                        "LIMIT @ItemsPerPage;", db);

                    selectCommand.Parameters.AddWithValue("@Name", ((object)filterString) != null ? "%" + filterString + "%" : "");
                    selectCommand.Parameters.AddWithValue("@CompanyId", ((object)filterString) != null ? companyId : 0);
                    selectCommand.Parameters.AddWithValue("@ItemsPerPage", 100);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        CountryViewModel dbEntry = Read(query);
                        countries.Add(dbEntry);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.Countries      = new List <CountryViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success   = true;
            response.Countries = countries;
            return(response);
        }
        public JsonResult GetCountries(int companyId)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response = countryService.GetCountries(companyId);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
                Console.WriteLine(ex.Message);
            }
            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
        public JsonResult Sync([FromBody] SyncCountryRequest request)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response = this.countryService.Sync(request);
            }
            catch (Exception ex)
            {
                response.Success = false;
                response.Message = ex.Message;
            }

            return(Json(response, new Newtonsoft.Json.JsonSerializerSettings()
            {
                Formatting = Newtonsoft.Json.Formatting.Indented
            }));
        }
Esempio n. 9
0
        public CountryListResponse GetCountries(int companyId)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response.Countries = unitOfWork.GetCountryRepository().GetCountries(companyId)
                                     .ConvertToCountryViewModelList();
                response.Success = true;
            }
            catch (Exception ex)
            {
                response.Countries = new List <CountryViewModel>();
                response.Success   = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
        public CountryListResponse GetCountries(int companyId)
        {
            CountryListResponse response = new CountryListResponse();

            try
            {
                response = WpfApiHandler.GetFromApi <List <CountryViewModel>, CountryListResponse>("GetCountries", new Dictionary <string, string>()
                {
                    { "CompanyId", companyId.ToString() }
                });
            }
            catch (Exception ex)
            {
                response.Countries = new List <CountryViewModel>();
                response.Success   = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
 public UserProfilePage()
 {
     InitializeComponent();
     _objEditProfileResponse = new EditProfileResponse();
     _apiService             = new RestApi();
     _objHeaderModel         = new HeaderModel();
     _apiServices            = new RestApi();
     _objCountryListResponse = new CountryListResponse();
     _baseUrlEdit            = Settings.Url + Domain.EditUserApiConstant;
     _baseUrlUpdate          = Settings.Url + Domain.UpdateUserApiConstant;
     _baseUrl = Domain.GetCountryApiConstant;
     LoadUserProfileData();
     LoadCountryData();
     _objUpdateProfileResponse = new UpdateProfileResponse();
     if (Settings.ProfilePicture == string.Empty)
     {
         imgProfile.Source = "profile.png";
     }
     else
     {
         imgProfile.Source = Settings.ProfilePicture;
     }
 }
        public dynamic GetCountryList()
        {
            //List<DropDownCL> drpList = new List<DropDownCL>();
            List <Country> countryList = new List <Country>();

            try
            {
                CountryListRequest Country = new CountryListRequest();
                Country.ClientId  = apiClientId;
                Country.EndUserIp = IPAddress;
                Country.TokenId   = BLFunction.GetTokenID();
                var    jsonObject   = JsonConvert.SerializeObject(Country);
                String QualifiedUrl = Baseurl + "SharedServices/SharedData.svc/rest/CountryList";
                var    result       = APIHotel.Instance().GetResponse(QualifiedUrl, Verbs.POST, jsonObject);
                if (result != null)
                {
                    CountryListResponse response = new CountryListResponse();
                    response    = JsonConvert.DeserializeObject <CountryListResponse>(result);
                    countryList = (List <Country>)GetObjectFromXMlString(typeof(List <Country>), "Countries", response.CountryList);

                    //foreach (var item in CountryList)
                    //{
                    //    DropDownCL ddcl = new DropDownCL();
                    //    ddcl.DataText = item.Name;
                    //    ddcl.DataValue = item.Code;
                    //    drpList.Add(ddcl);
                    //}
                }
                return(countryList);
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
                return(null);
            }
        }
Esempio n. 13
0
        public CountryListResponse GetCountriesByPage(int companyId, CountryViewModel countrySearchObject, int currentPage = 1, int itemsPerPage = 50)
        {
            CountryListResponse     response  = new CountryListResponse();
            List <CountryViewModel> Countries = new List <CountryViewModel>();

            using (SqliteConnection db = new SqliteConnection("Filename=SirmiumERPGFC.db"))
            {
                db.Open();
                try
                {
                    SqliteCommand selectCommand = new SqliteCommand(
                        SqlCommandSelectPart +
                        "FROM Countries " +
                        "WHERE (@AlfaCode IS NULL OR @AlfaCode = '' OR AlfaCode LIKE @AlfaCode)  " +
                        "AND (@NumericCode IS NULL OR @NumericCode = '' OR NumericCode LIKE @NumericCode) " +
                        "AND (@Mark IS NULL OR @Mark = '' OR Mark LIKE @Mark) " +
                        "AND (@Name IS NULL OR @Name = '' OR Name LIKE @Name) " +
                        "AND CompanyId = @CompanyId " +
                        "ORDER BY IsSynced DESC, Name ASC " +
                        "LIMIT @ItemsPerPage OFFSET @Offset;", db);

                    selectCommand.Parameters.AddWithValue("@Name", ((object)countrySearchObject.Search_Name) != null ? "%" + countrySearchObject.Search_Name + "%" : "");
                    selectCommand.Parameters.AddWithValue("@AlfaCode", ((object)countrySearchObject.Search_AlfaCode) != null ? "%" + countrySearchObject.Search_AlfaCode + "%" : "");
                    selectCommand.Parameters.AddWithValue("@NumericCode", ((object)countrySearchObject.Search_NumericCode) != null ? "%" + countrySearchObject.Search_NumericCode + "%" : "");
                    selectCommand.Parameters.AddWithValue("@Mark", ((object)countrySearchObject.Search_Mark) != null ? "%" + countrySearchObject.Search_Mark + "%" : "");
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);
                    selectCommand.Parameters.AddWithValue("@ItemsPerPage", itemsPerPage);
                    selectCommand.Parameters.AddWithValue("@Offset", (currentPage - 1) * itemsPerPage);

                    SqliteDataReader query = selectCommand.ExecuteReader();

                    while (query.Read())
                    {
                        CountryViewModel dbEntry = Read(query);
                        Countries.Add(dbEntry);
                    }


                    selectCommand = new SqliteCommand(
                        "SELECT Count(*) " +
                        "FROM Countries " +
                        "WHERE (@AlfaCode IS NULL OR @AlfaCode = '' OR AlfaCode LIKE @AlfaCode)  " +
                        "AND (@NumericCode IS NULL OR @NumericCode = '' OR NumericCode LIKE @NumericCode) " +
                        "AND (@Mark IS NULL OR @Mark = '' OR Mark LIKE @Mark) " +
                        "AND (@Name IS NULL OR @Name = '' OR Name = @Name) " +
                        "AND CompanyId = @CompanyId;", db);

                    selectCommand.Parameters.AddWithValue("@Name", ((object)countrySearchObject.Search_Name) != null ? "%" + countrySearchObject.Search_Name + "%" : "");
                    selectCommand.Parameters.AddWithValue("@AlfaCode", ((object)countrySearchObject.Search_AlfaCode) != null ? "%" + countrySearchObject.Search_AlfaCode + "%" : "");
                    selectCommand.Parameters.AddWithValue("@NumericCode", ((object)countrySearchObject.NumericCode) != null ? "%" + countrySearchObject.NumericCode + "%" : "");
                    selectCommand.Parameters.AddWithValue("@Mark", ((object)countrySearchObject.Mark) != null ? "%" + countrySearchObject.Mark + "%" : "");
                    selectCommand.Parameters.AddWithValue("@CompanyId", companyId);

                    query = selectCommand.ExecuteReader();

                    if (query.Read())
                    {
                        response.TotalItems = query.GetInt32(0);
                    }
                }
                catch (SqliteException error)
                {
                    MainWindow.ErrorMessage = error.Message;
                    response.Success        = false;
                    response.Message        = error.Message;
                    response.Countries      = new List <CountryViewModel>();
                    return(response);
                }
                db.Close();
            }
            response.Success   = true;
            response.Countries = Countries;
            return(response);
        }
Esempio n. 14
0
        public void Sync(ICountryService countryService, Action <int, int> callback = null)
        {
            try
            {
                SyncCountryRequest request = new SyncCountryRequest();
                request.CompanyId     = MainWindow.CurrentCompanyId;
                request.LastUpdatedAt = GetLastUpdatedAt(MainWindow.CurrentCompanyId);

                int toSync      = 0;
                int syncedItems = 0;

                CountryListResponse response = countryService.Sync(request);
                if (response.Success)
                {
                    toSync = response?.Countries?.Count ?? 0;
                    List <CountryViewModel> countrysFromDB = response.Countries;

                    using (SqliteConnection db = new SqliteConnection(SQLiteHelper.SqLiteTableName))
                    {
                        db.Open();
                        using (var transaction = db.BeginTransaction())
                        {
                            SqliteCommand deleteCommand = db.CreateCommand();
                            deleteCommand.CommandText = "DELETE FROM Countries WHERE Identifier = @Identifier";

                            SqliteCommand insertCommand = db.CreateCommand();
                            insertCommand.CommandText = SqlCommandInsertPart;

                            foreach (var country in countrysFromDB)
                            {
                                deleteCommand.Parameters.AddWithValue("@Identifier", country.Identifier);
                                deleteCommand.ExecuteNonQuery();
                                deleteCommand.Parameters.Clear();

                                if (country.IsActive)
                                {
                                    country.IsSynced = true;

                                    insertCommand = AddCreateParameters(insertCommand, country);
                                    insertCommand.ExecuteNonQuery();
                                    insertCommand.Parameters.Clear();

                                    syncedItems++;
                                    callback?.Invoke(syncedItems, toSync);
                                }
                            }

                            transaction.Commit();
                        }
                        db.Close();
                    }
                }
                else
                {
                    throw new Exception(response.Message);
                }
            }
            catch (Exception ex)
            {
                MainWindow.ErrorMessage = ex.Message;
            }
        }