public List <BuffAndEffectCommand> SP_GetBuffAndEffectCommands_Old(int buffAndEffectId) { List <BuffAndEffectCommand> _buffAndEffectCommand = new List <BuffAndEffectCommand>(); string connectionString = _configuration.GetSection("ConnectionStrings").GetSection("DefaultConnection").Value; SqlConnection connection = new SqlConnection(connectionString); SqlCommand command = new SqlCommand(); SqlDataAdapter adapter = new SqlDataAdapter(); DataSet ds = new DataSet(); try { connection.Open(); command = new SqlCommand("BuffAndEffect_GetCommands", connection); // Add the parameters for the SelectCommand. command.Parameters.AddWithValue("@BuffAndEffectId", buffAndEffectId); command.CommandType = CommandType.StoredProcedure; adapter.SelectCommand = command; adapter.Fill(ds); command.Dispose(); connection.Close(); } catch (Exception ex) { command.Dispose(); connection.Close(); } if (ds.Tables[0].Rows.Count > 0) { foreach (DataRow row in ds.Tables[0].Rows) { BuffAndEffectCommand _cmd = new BuffAndEffectCommand(); _cmd.Command = row["Command"] == DBNull.Value ? null : row["Command"].ToString(); _cmd.BuffAndEffectId = row["BuffAndEffectId"] == DBNull.Value ? 0 : Convert.ToInt32(row["BuffAndEffectId"].ToString()); _cmd.BuffAndEffectCommandId = row["BuffAndEffectCommandId"] == DBNull.Value ? 0 : Convert.ToInt32(row["BuffAndEffectCommandId"].ToString()); _cmd.IsDeleted = row["IsDeleted"] == DBNull.Value ? false : Convert.ToBoolean(row["IsDeleted"]); _cmd.Name = row["Name"] == DBNull.Value ? null : row["Name"].ToString(); _buffAndEffectCommand.Add(_cmd); } } return(_buffAndEffectCommand); }
public async Task <BuffAndEffectCommand> UdateBuffAndEffectCommand(BuffAndEffectCommand buffAndEffectCommand) { var ac = _context.BuffAndEffectCommands.Find(buffAndEffectCommand.BuffAndEffectCommandId); if (ac == null) { return(buffAndEffectCommand); } try { ac.Command = buffAndEffectCommand.Command; ac.Name = buffAndEffectCommand.Name; _context.SaveChanges(); } catch (Exception ex) { throw ex; } return(ac); }
public async Task <BuffAndEffectCommand> InsertBuffAndEffectCommand(BuffAndEffectCommand buffAndEffectCommand) { _context.BuffAndEffectCommands.Add(buffAndEffectCommand); _context.SaveChanges(); return(buffAndEffectCommand); }