public object Post2([FromBody] Models.Condominio value) { var json = System.IO.File.ReadAllText(@"Data\dbCondo.json"); var condo = JsonConvert.DeserializeObject <List <Models.Condominio> >(json); condo.Add(value); var json_w = JsonConvert.SerializeObject(condo, Formatting.Indented); System.IO.File.WriteAllText(@"Data\dbCondo.json", json_w); string a = ("Condominio Cadatrado com Sucesso"); return(a); }
public object Post2([FromBody] Models.Condominio value) { var json = System.IO.File.ReadAllText(@"Data\dbCondo.json"); var user = JsonConvert.DeserializeObject <List <Models.Condominio> >(json); try { int y = user.IndexOf(user.First(x => x.Con_cnpj.Equals(value.Con_cnpj))); user[y] = value; var json_w = JsonConvert.SerializeObject(user, Formatting.Indented); System.IO.File.WriteAllText(@"Data\dbCondo.json", json_w); return(user[y]); } catch (System.InvalidOperationException) { string a = ("erro usuario inexistente"); return(a); } }