For a project I'm working on, I have to create a web service in c# asp.net web api 2. Right now, I have a basic web service, that when the client calls the service it returns json. This is what I have:
ProductController
public class ProductController : ApiController
{
public List<Dictionary<string, object>> Get()
{
ProductRepository er = new ProductRepository();
return getDataRows(er.getModifiedProducts());
}
private List<Dictionary<string, object>> getDataRows(DataTable dt)
{
List<Dictionary<string, object>> rows = new List<Dictionary<string, object>>();
Dictionary<string, object> row;
foreach (DataRow dr in dt.Rows)
{
row = new Dictionary<string, object>();
foreach (DataColumn col in dt.Columns)
{
string output = Regex.Replace(Convert.ToString(col.ColumnName), "[.]", "\\.");
row.Add(output, Convert.ToString(dr[col]));
}
rows.Add(row);
}
return rows;
}
}
When a client does a call to the service, it gets all modified products. When the client has all the data received, I want to update the product status, so that when the client does a second call, the products from the first call aren't sent anymore. Before the service can do the update, It has to be sure that the client has received the complete dataset. I was thinking of something with a callback, but I don't know where to start. Can you please give me some pointers?