public CuponsVM() { CupomResp = new CupomModel(); ListaCuponsView = new List <Cupon>(); //MostraPopUpCommand = new Command(MostraPopUp); NoVoCupomCommand = new Command(NoVoCupom); PovoarListaCupons(); }
protected override void ToEntidade() { CupomModel vm = (CupomModel)ViewModel; Entidades[typeof(Cupom).Name] = new Cupom { Valor = vm.Valor, Codigo = vm.Codigo }; }
protected override void ToViewModel() { Cupom cupom = (Cupom)Entidades[typeof(Cupom).Name]; CupomModel vm = new CupomModel { Codigo = cupom.Codigo.ToString(), Valor = (double)cupom.Valor }; _viewModel = vm; }
//CUPONS * public static CupomModel GetCupons(string cnpj) { string URL = "https://ganhemais.site/api/Cupom.php?cnpj={0}"; string NovoURL = string.Format(URL, cnpj); WebClient wc = new WebClient(); string Conteudo = wc.DownloadString(NovoURL); CupomModel cupons = new CupomModel(); cupons = Task.Run(() => { return(JsonConvert.DeserializeObject <CupomModel>(Conteudo)); }).Result; return(cupons); }