Ejemplo n.º 1
0
 public JsonResult Post(string table, [FromBody] JObject parameters)
 {
     try
     {
         MarketContext MC = new MarketContext();
         MC.CreateConnection();
         if (MC.Connected())
         {
             return(Json(MC.Insert(table, parameters)));
         }
         else
         {
             throw new Exception("Connection failed");
         }
     }
     catch (Exception ex)
     {
         return(Json("Error: " + ex.Message));
     }
 }
Ejemplo n.º 2
0
 public JsonResult Get(string table, string filter)
 {
     try
     {
         MarketContext MC = new MarketContext();
         MC.CreateConnection();
         if (MC.Connected())
         {
             return(Json(MC.Select(table, filter)));
         }
         else
         {
             throw new Exception("Connection failed");
         }
     }
     catch (Exception ex)
     {
         return(Json("Error: " + ex.Message));
     }
 }
Ejemplo n.º 3
0
 public JsonResult Delete(string table, int id)
 {
     try
     {
         MarketContext MC = new MarketContext();
         MC.CreateConnection();
         if (MC.Connected())
         {
             return(Json(MC.Delete(table, id)));
         }
         else
         {
             throw new Exception("Connection failed");
         }
     }
     catch (Exception ex)
     {
         return(Json("Error: " + ex.Message));
     }
 }
Ejemplo n.º 4
0
        public JsonResult Delete(string table, string filter)
        {
            string FullTable = "public." + '"' + table + '"';

            try
            {
                MarketContext MC = new MarketContext();
                MC.CreateConnection();
                if (MC.Connected())
                {
                    return(Json(MC.Delete(FullTable, filter)));
                }
                else
                {
                    throw new Exception("Connection failed");
                }
            }
            catch (Exception ex)
            {
                return(Json("Error: " + ex.Message));
            }
        }