public void CreateAlbum(albumDAO albumToCreate) { try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("Sp_CreateAlbum", _connection)) { _command.CommandType = CommandType.StoredProcedure; _command.Parameters.AddWithValue("@Name", albumToCreate.AlbumName); _command.Parameters.AddWithValue("@Description", albumToCreate.AlbumDescription); _command.Parameters.AddWithValue("@Price", albumToCreate.AlbumPrice); _command.Parameters.AddWithValue("@YearReleased", albumToCreate.YearReleased); _command.Parameters.AddWithValue("@NumberOfSongs", albumToCreate.NumberOfSongs); _command.Parameters.AddWithValue("@AlbumQuantity", albumToCreate.AlbumQuantity); _connection.Open(); _command.ExecuteNonQuery(); _connection.Close(); _connection.Dispose(); } } } catch (Exception _Error) { Error_Logger Log = new Error_Logger(); Log.Errorlogger(_Error); } }
public bool DeleteAlbum(albumDAO albumToDelete) { bool yes = false; try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("Sp_DeleteAlbum", _connection)) { _command.CommandType = CommandType.StoredProcedure; _command.Parameters.AddWithValue("@Albums_ID", albumToDelete.Albums_ID); _connection.Open(); _command.ExecuteNonQuery(); yes = true; _connection.Close(); } } } catch (Exception _Error) { Error_Logger Log = new Error_Logger(); Log.Errorlogger(_Error); } if (yes == true) { } return(yes); }
public ActionResult UpdateAlbum(Album _AlbumInfo) { if ((int)Session["Role_ID"] == 3 || (int)Session["Role_ID"] == 2) { albumDAO _recievedAlbum = _mapper.SingleAlbum(_AlbumInfo); _AlbumDataAccess.UpdateAlbum(_recievedAlbum); } return(RedirectToAction("AlbumView")); }
public ActionResult CreateAlbum(Album newAlbum) { if ((int)Session["Role_ID"] == 3 || (int)Session["Role_ID"] == 2) { albumDAO AlbumToCreate = _mapper.SingleAlbum(newAlbum); _AlbumDataAccess.CreateAlbum(AlbumToCreate); } return(RedirectToAction("AlbumView")); }
public ActionResult DeleteAlbum(int Delete_Album) { if ((int)Session["Role_ID"] == 3) { albumDAO _DeleteAlbum = new albumDAO(); _DeleteAlbum.Albums_ID = Delete_Album; _AlbumDataAccess.DeleteAlbum(_DeleteAlbum); } return(RedirectToAction("AlbumView")); }
public albumDAO SingleAlbum(Album _SingleAlbumToMap) { albumDAO AlbumToReturn = new albumDAO(); { albumDAO _albumToView = new albumDAO(); _albumToView.Albums_ID = _SingleAlbumToMap.Albums_ID; _albumToView.AlbumName = _SingleAlbumToMap.AlbumName; _albumToView.AlbumDescription = _SingleAlbumToMap.AlbumDescription; _albumToView.AlbumPrice = _SingleAlbumToMap.AlbumPrice; _albumToView.YearReleased = _SingleAlbumToMap.YearReleased; _albumToView.NumberOfSongs = _SingleAlbumToMap.NumberOfSongs; _albumToView.AlbumQuantity = _SingleAlbumToMap.AlbumQuantity; AlbumToReturn = _albumToView; } return(AlbumToReturn); }
public Album SelectAlbum(albumDAO _SelectAlbumToMap) { Album AlbumToReturn = new Album(); { Album _albumToView = new Album(); _albumToView.Albums_ID = _SelectAlbumToMap.Albums_ID; _albumToView.AlbumName = _SelectAlbumToMap.AlbumName; _albumToView.AlbumDescription = _SelectAlbumToMap.AlbumDescription; _albumToView.AlbumPrice = _SelectAlbumToMap.AlbumPrice; _albumToView.YearReleased = _SelectAlbumToMap.YearReleased; _albumToView.NumberOfSongs = _SelectAlbumToMap.NumberOfSongs; _albumToView.AlbumQuantity = _SelectAlbumToMap.AlbumQuantity; AlbumToReturn = _albumToView; } return(AlbumToReturn); }
public List <albumDAO> GetAllAlbums() { List <albumDAO> _albumlist = new List <albumDAO>(); try { using (SqlConnection _connection = new SqlConnection(connectionstring)) { using (SqlCommand _command = new SqlCommand("Sp_ViewAlbums", _connection)) { _command.CommandType = CommandType.StoredProcedure; _connection.Open(); using (SqlDataReader _reader = _command.ExecuteReader()) { while (_reader.Read()) { albumDAO _albumToList = new albumDAO(); _albumToList.Albums_ID = _reader.GetInt32(0); _albumToList.AlbumName = _reader.GetString(1); _albumToList.AlbumDescription = _reader.GetString(2); _albumToList.AlbumPrice = _reader.GetDecimal(3); _albumToList.YearReleased = _reader.GetDateTime(4); _albumToList.NumberOfSongs = _reader.GetInt32(5); _albumToList.AlbumQuantity = _reader.GetInt32(6); _albumlist.Add(_albumToList); } } } } } catch (Exception _Error) { Error_Logger Log = new Error_Logger(); Log.Errorlogger(_Error); } return(_albumlist); }