public string this[string columnName] { get { if (columnName == "From") { if (From == null) { return("Request From is required"); } } if (columnName == "To") { if (To == null) { return("Request to is required"); } } if (columnName == "NumDays") { if (string.IsNullOrEmpty(NumDays.ToString())) { return("Number of days is required"); } } return(string.Empty); } }
public string this[string columnName] { get { if (columnName == "From") { if (From == null) { return("Request From is required"); } } if (columnName == "To") { if (To == null) { return("Request to is required"); } } if (columnName == "NumDays") { if (string.IsNullOrEmpty(NumDays.ToString())) { return("Number of days is required"); } if (!LeaveProxy.ValidateNumberOfLeaveDays(NumDays, EmployeeId)) { return("Number of days is invalid"); } } return(string.Empty); } }
public async override void OnPerformSync(Android.Accounts.Account account, Android.OS.Bundle extras, string authority, ContentProviderClient provider, SyncResult syncResult) { Log.WriteLine(LogPriority.Debug, _tag, "Starting sync"); try { var locationQuery = Utility.GetPreferredLocation(Context); // Constants for URL const string Url = "api.openweathermap.org"; const string Path = "data/2.5/forecast/daily"; const string Scheme = "http"; // Constants for parameters const string Format = "json"; const string Units = "metric"; const int NumDays = 14; const string AppId = "582900aa4d4687a5711f7704ae16611a"; var builder = new UriBuilder(); var client = new HttpClient(new NativeMessageHandler()); builder.Host = Url; builder.Path = Path; builder.Scheme = Scheme; var query = HttpUtility.ParseQueryString(builder.Query); query["mode"] = Format; query["units"] = Units; query["cnt"] = NumDays.ToString(); query["appid"] = AppId; query["q"] = locationQuery; builder.Query = query.ToString(); HttpResponseMessage response = await client.GetAsync(builder.Uri); var responseJson = await response.Content.ReadAsStringAsync(); GetWeatherDataFromJson(responseJson, locationQuery); } catch (Java.Net.UnknownHostException e) { Log.WriteLine(LogPriority.Debug, _tag, $"Download failed with result {e.Message}"); } catch (JsonSerializationException e) { Log.WriteLine(LogPriority.Debug, _tag, $"Json parser failed with error {e.Message}"); } return; }