Exemplo n.º 1
0
 public IHttpActionResult PostDecoder(Decoder decoder)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var services = new DecoderServices();
         if (decoder.Id == null)
         {
             var decoderId = services.AddDecoder(decoder);
             MyHub.NotifyRefresh();
             return(Json(new { id = decoderId }));
         }
         else
         {
             var mustRefreshToolbox = services.UpdateDecoder(decoder);
             if (mustRefreshToolbox)
             {
                 MyHub.NotifyRefresh();
             }
             return(Json(new { id = decoder.Id }));
         }
     }
     catch (Exception e)
     {
         return(InternalServerError(e));
     }
 }
        public string PostDecoder(Decoder decoder)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    //return BadRequest(ModelState);
                    return("not valid model");
                }
                if (decoder == null)
                {
                    return("erreur lors du transfert de données vers le serveur");
                }

                var services = new DecoderServices();
                if (decoder.Id == null)
                {
                    services.AddDecoder(decoder);
                    return(decoder.Id.ToString());
                }
                else
                {
                    services.UpdateDecoder(decoder.Id, decoder.Xml, decoder.Code);
                    return("id=" + decoder.Id);
                }
            }
            catch (Exception e)
            {
                return(e.ToString());
            }
        }
Exemplo n.º 3
0
 public IHttpActionResult GetDecoderDef([FromBody] int?id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var services = new DecoderServices();
         var decoder  = services.GetDecoder(id);
         return(Json(new { decoder.Name, decoder.Version, decoder.Category, decoder.Tags, decoder.BlocklyDef }));
     }
     catch (Exception e)
     {
         return(InternalServerError(e));
     }
 }
Exemplo n.º 4
0
 public IHttpActionResult FindUsages([FromBody] int?id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
         }
         var services = new DecoderServices();
         var list     = services.FindProcedureUsages(id);
         return(Json(list.ToArray()));
     }
     catch (Exception e)
     {
         //return Json(new { error = e.ToString() });
         return(InternalServerError(e));
     }
 }
Exemplo n.º 5
0
 public IHttpActionResult DeleteDecoder([FromBody] int?id)
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
             //return Json(new { error = "modèle non valide" });
         }
         var services = new DecoderServices();
         services.DeleteDecoder(id);
         return(Ok());
     }
     catch (Exception e)
     {
         //return Json(new { error = e.ToString() });
         return(InternalServerError(e));
     }
 }
Exemplo n.º 6
0
 public IHttpActionResult GetAllBlockInfos()
 {
     try
     {
         if (!ModelState.IsValid)
         {
             return(BadRequest(ModelState));
             //return Json(new { error = "modèle non valide" });
         }
         var services = new DecoderServices();
         //var map = services.GetCategoryInfos();
         //return Json(new JavaScriptSerializer().Serialize(map));
         var list = services.GetAllBlockInfos();
         return(Json(list.ToArray()));
     }
     catch (Exception e)
     {
         //return Json(new { error = e.ToString() });
         return(InternalServerError(e));
     }
 }