public void Remove() { Task.Run(() => { CacheResource.Remove(); Data = null; }); }
public void Get(string _Input = null) { // Fetch if (_Input == null) { // Loog for stored pass ResourceResponse Response = CacheResource.Get(); if (Response.IsValid) { SeasonPassModel Pass = JsonConvert.DeserializeObject <SeasonPassModel>(Response.Data); if (IsPassValid(Pass.ValidTo)) { Data = Pass; } else { Data = null; IsPassInvalidEvent?.Invoke(this, EventArgs.Empty); } } } else { string InputEncrypted = EncDecService.Hash(_Input); if (ApiResource.Headers.ContainsKey("PassID")) { ApiResource.Headers["PassID"] = InputEncrypted; } else { ApiResource.Headers.Add("PassID", InputEncrypted); } ResourceResponse Response = ApiResource.Get(); if (Response.IsValid) { List <SeasonPassModel> Temp = JsonConvert.DeserializeObject <List <SeasonPassModel> >(Response.Data); if (Temp.Count > 0) { SeasonPassModel Pass = Temp[0]; if (IsPassValid(Pass.ValidTo)) { CacheResource.AddOrUpdate(JsonConvert.SerializeObject(Pass)); Data = Pass; } else { IsPassInvalidEvent?.Invoke(this, EventArgs.Empty); Data = null; } } else { IsPassInvalidEvent?.Invoke(this, EventArgs.Empty); Data = null; } } } // Decrypt if (Data != null) { Data.Holder = EncDecService.Decrypt(Data.Holder); } }