Ejemplo n.º 1
0
        public HttpResponseMessage addMusicList()
        {
            string list_name = encode_result["list_name"];

            if (list_name != null)
            {
                MusicLists musicLists = new MusicLists {
                    user_id = user_id, list_name = list_name
                };
                db.MusicLists.Add(musicLists);
                db.SaveChanges();
                result = new HttpResponseMessage(HttpStatusCode.OK);
            }
            else
            {
                result = new HttpResponseMessage(HttpStatusCode.NoContent);
            }

            return(result);
        }
Ejemplo n.º 2
0
        public HttpResponseMessage deleteList()
        {
            string list_id = HttpContext.Current.Request.Form["list_id"];

            int lid = int.Parse(list_id);

            if (lid != 0)
            {
                MusicLists musicLists = db.MusicLists.Where(a => a.Id == lid).FirstOrDefault();
                db.MusicLists.Remove(musicLists);
                List <MusicList> musicList = db.MusicList.Where(a => a.list_id == lid).ToList();
                db.MusicList.RemoveRange(musicList);
                db.SaveChanges();
                result = new HttpResponseMessage(HttpStatusCode.OK);
            }
            else
            {
                result = new HttpResponseMessage(HttpStatusCode.NoContent);
            }

            return(result);
        }
Ejemplo n.º 3
0
 public static int ReadConfig()
 {
     var deserializer = new Deserializer();
     try {
         using (StreamReader input = new StreamReader(configFile))
         {
             settings = deserializer.Deserialize<AMESettings>(input);
         }
     }
     catch (FileNotFoundException ex)
     {
         FileNotFound(ex);
         return -1;
     }
     catch (YamlException ex)
     {
         
         ShowMessageBox(rmInternalStrings.GetString("UnableToReadConfig") + " " + configFile + ".\n\n" + ex.Message, rmInternalStrings.GetString("UnableToReadConfigTitle"), "OK", "Error");
         return -1;
     }
     try
     {
         using (StreamReader input = new StreamReader(gamesFile))
         {
             gameList = deserializer.Deserialize<GameList>(input);
         }
     }
     catch (FileNotFoundException ex)
     {
         FileNotFound(ex);
         return -1;
     }
     catch (YamlException ex)
     {
         
         ShowMessageBox(rmInternalStrings.GetString("UnableToReadConfig") + " " + gamesFile + ".\n\n" + ex.Message, rmInternalStrings.GetString("UnableToReadConfigTitle"), "OK", "Error");
         return -1;
     }
     try
     {
         using (StreamReader input = new StreamReader(tableFile))
         {
             charTable = deserializer.Deserialize<CharTable>(input);
         }
     }
     catch (FileNotFoundException ex)
     {
         FileNotFound(ex);
         return -1;
     }
     catch (YamlException ex)
     {
         
         ShowMessageBox(rmInternalStrings.GetString("UnableToReadConfig") + " " + tableFile + ".\n\n" + ex.Message, rmInternalStrings.GetString("UnableToReadConfigTitle"), "OK", "Error");
         return -1;
     }
     try
     {
         using (StreamReader input = new StreamReader(behaviorBytesFile))
         {
             behaviorLists = deserializer.Deserialize<BehaviorLists>(input);
         }
     }
     catch (FileNotFoundException ex)
     {
         FileNotFound(ex);
         return -1;
     }
     catch (YamlException ex)
     {
         
         ShowMessageBox(rmInternalStrings.GetString("UnableToReadConfig") + " " + behaviorBytesFile + ".\n\n" + ex.Message, rmInternalStrings.GetString("UnableToReadConfigTitle"), "OK", "Error");
         return -1;
     }
     try
     {
         using (StreamReader input = new StreamReader(musicListFile))
         {
             musicLists = deserializer.Deserialize<MusicLists>(input);
         }
     }
     catch (FileNotFoundException ex)
     {
         FileNotFound(ex);
         return -1;
     }
     catch (YamlException ex)
     {
         
         ShowMessageBox(rmInternalStrings.GetString("UnableToReadConfig") + " " + musicListFile + ".\n\n" + ex.Message, rmInternalStrings.GetString("UnableToReadConfigTitle"), "OK", "Error");
         return -1;
     }
     return 0;
 }