public IHttpActionResult PuttInfo(int id, tInfo tInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != tInfo.fInfoId) { return(BadRequest()); } db.Entry(tInfo).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!tInfoExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private static int SetRecord(MP3Record mp3Record) { int lastSongID = -1; if (MD5Exist(mp3Record.MD5, false) == false) { try { var context = new MyJukeboxEntities(); // tsongs data var songs = new tSong(); songs.Album = mp3Record.Album; songs.Artist = mp3Record.Artist; songs.Titel = mp3Record.Titel; songs.Pfad = mp3Record.Path; songs.FileName = mp3Record.FileName; songs.ID_Genre = mp3Record.Genre; songs.ID_Catalog = mp3Record.Catalog; songs.ID_Media = mp3Record.Media; context.tSongs.Add(songs); context.SaveChanges(); lastSongID = GetLastID("tSongs"); // tmd5 data var md5 = new tMD5(); md5.MD5 = mp3Record.MD5; md5.ID_Song = lastSongID; context.tMD5.Add(md5); context.SaveChanges(); // tfileinfo data var file = new tFileInfo(); file.FileDate = mp3Record.FileDate; file.FileSize = mp3Record.FileSize; file.ImportDate = DateTime.Now; file.ID_Song = lastSongID; context.tFileInfos.Add(file); context.SaveChanges(); // tinfos data var info = new tInfo(); info.Sampler = mp3Record.IsSample; info.ID_Song = lastSongID; context.tInfos.Add(info); context.SaveChanges(); return(1); } catch (Exception ex) { Debug.Print($"SetNewRecord_Error: {ex.Message}"); return(0); } } else { return(0); } }
public IHttpActionResult GettInfo(int id) { tInfo tInfo = db.tInfoes.Find(id); if (tInfo == null) { return(NotFound()); } return(Ok(tInfo)); }
public IHttpActionResult PosttInfo(tInfo tInfo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.tInfoes.Add(tInfo); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = tInfo.fInfoId }, tInfo)); }
public IHttpActionResult DeletetInfo(int id) { tInfo tInfo = db.tInfoes.Find(id); if (tInfo == null) { return(NotFound()); } db.tInfoes.Remove(tInfo); db.SaveChanges(); return(Ok(tInfo)); }
public void CreateDB(string FileDB) { try { InitDB(FileDB); ActiveRecordStarter.CreateSchema(); tInfo otInfo = new tInfo(); otInfo.Version_DB = Resources.Version_DB_01; otInfo.SaveAndFlush(); } catch (Exception exception) { MessageBox.Show(exception.ToString()); } }