Beispiel #1
0
        public object Post3([FromBody] Models.Reservas value)
        {
            var json    = System.IO.File.ReadAllText(@"Data\dbReservas.json");
            var reserva = JsonConvert.DeserializeObject <List <Models.Reservas> >(json);

            reserva.Add(value);

            var json_w = JsonConvert.SerializeObject(reserva, Formatting.Indented);

            System.IO.File.WriteAllText(@"Data\dbReservas.json", json_w);

            string a = ("Condominio Cadatrado com Sucesso");

            return(a);
        }
Beispiel #2
0
        public object Post1([FromBody] Models.Reservas value)
        {
            var json = System.IO.File.ReadAllText(@"Data\dbReservas.json");
            var user = JsonConvert.DeserializeObject <List <Models.Reservas> >(json);

            try
            {
                int y = user.IndexOf(user.First(x => x.Reserva_user.Equals(value.Reserva_user) && x.Reserva_area.Equals(value.Reserva_area) && x.Reserva_data.Equals(value.Reserva_data)));
                user.Remove(user[y]);
                var json_w = JsonConvert.SerializeObject(user, Formatting.Indented);
                System.IO.File.WriteAllText(@"Data\dbReservas.json", json_w);
                return("erro");
            }
            catch (System.InvalidOperationException)
            {
                string a = ("erro usuario inexistente");
                return(a);
            }
        }