public bool UpdateAccu(AccuDto accu) { try { _connection.Open(); var cmd = new SqlCommand( "UPDATE Accu SET name = @name, creatorid = @creatorid, specs = @specs WHERE id = @id", _connection); cmd.Parameters.AddWithValue("@id", accu.Id); cmd.Parameters.AddWithValue("@name", accu.Name); cmd.Parameters.AddWithValue("@creatorid", accu.Creatorid); cmd.Parameters.AddWithValue("@specs", accu.Specs ?? " "); cmd.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e); return(false); } finally { _connection.Close(); } return(true); }
public bool AddAccu(AccuDto accu) { try { _connection.Open(); var cmd = new SqlCommand("INSERT INTO Accu (name, creatorid, specs) VALUES (@name, @creatorid, @specs)", _connection); cmd.Parameters.AddWithValue("@name", accu.Name); cmd.Parameters.AddWithValue("@creatorid", accu.Creatorid); cmd.Parameters.AddWithValue("@specs", accu.Specs ?? " "); cmd.ExecuteNonQuery(); } catch (Exception e) { Console.WriteLine(e); return(false); } finally { _connection.Close(); } return(true); }
public Accu(AccuDto accu) { this.Id = accu.Id; this.Name = accu.Name; this.Creator = new Account().GetAccountById(accu.Creatorid); this.Specs = accu.Specs; }