Beispiel #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());
            }
        }