public SongGetRequest Insert(SongInsertRequest song) { var entity = _mapper.Map <Song>(song); _context.Song.Add(entity); _context.SaveChanges(); return(_mapper.Map <SongGetRequest>(_context.Song.Last())); }
public SongGetRequest Update(int id, SongInsertRequest obj) { var entity = _context.Song.Find(id); if (entity != null) { _context.Song.Attach(entity); _context.Song.Update(entity); entity.Title = obj.Title; entity.Text = obj.Text; entity.AlbumId = obj.AlbumId; _context.SaveChanges(); return(_mapper.Map <SongGetRequest>(entity)); } return(null); }
private async void btnSaveEditedSong_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { SongInsertRequest req = new SongInsertRequest(); req.Title = txtName.Text; req.Text = txtLyrics.Text; req.AlbumId = (int)cmbAlbum.SelectedValue; await _songService.Update <SongGetRequest>(_songId, req); Helper.HelperMethods.CloseAllForms(); frmSong frm = new frmSong(); frm.MdiParent = Application.OpenForms["frmIndex"]; frm.WindowState = FormWindowState.Maximized; frm.Show(); } }
private async void btnFinish_Click(object sender, EventArgs e) { if (this.ValidateChildren()) { SongInsertRequest req = new SongInsertRequest(); req.Title = txtName.Text; req.Text = txtLyrics.Text; req.AlbumId = (int)cmbAlbum.SelectedValue; await _songService.Insert <SongInsertRequest>(req, "AddSong"); this.Close(); frmSong frm = new frmSong(); frm.Show(); frm.MdiParent = Application.OpenForms["frmIndex"]; frm.WindowState = FormWindowState.Maximized; } }
/* methods */ public AddSongViewModel() { Title = "Add song"; SongReq = new SongInsertRequest(); }
public ActionResult <SongGetRequest> Update(int id, SongInsertRequest song) { return(_songService.Update(id, song)); }
public ActionResult <SongGetRequest> Insert(SongInsertRequest song) { return(_songService.Insert(song)); }