public async Task <int> Update(Task entity) { entity.DateModified = DateTime.Now; var sql = "UPDATE TASK1 SET Name = @Name, Description = @Description, Status = @Status, DueDate = @DueDate, DateModified = @DateModified WHERE Id = @Id;"; using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var affectedRows = await connection.ExecuteAsync(sql, entity); return(affectedRows); } }
public async Task <int> Add(Task entity) { entity.DateCreated = DateTime.Now; var sql = "INSERT INTO TASK1 (Name, Description, Status, DueDate, DateCreated) VALUES(@Name, @Description, @Status, @DueDate, @DateCreated);"; using (var connection = new SqlConnection(_configuration.GetConnectionString("DefaultConnection"))) { connection.Open(); var affectedRows = await connection.ExecuteAsync(sql, entity); return(affectedRows); } }