This is a migrated thread and some comments may be shown as answers.

Upload handler. Cannot return id of created items to client.

1 Answer 83 Views
Upload
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Evgeny
Top achievements
Rank 1
Evgeny asked on 10 Aug 2012, 11:05 AM
I am uploading few files and i want to return their ids to client. 

What i am do for that:

List<int> _listOfIds
public override Dictionary<string, object> GetAssociatedData()
{
 if (IsFinalUploadRequest())
            {
                dict.Add("MyIds", _listOfIds);
            }
}

  public override void ProcessStream()
  {
base.ProcessStream();

 if (IsFinalUploadRequest())
  { 

//CODE to save item to database.
int savedId=SomeId();
_listOfIds.Add(savedId );
}
}


Problem here that GetAssociatedData is called earlier than i will recieve item ID!! What i suppose to do?
Can i send GetAssociatedData() after my manipulations to store data in DB?

1 Answer, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 15 Aug 2012, 08:52 AM
Hi Evgeny,

In order to implement your solution, you need to override the SaveChunkData() method instead of the ProssessStream() method. I prepared a sample solution demonstrating a possible approach for your scenario - please note that I send over to the client side the id-s one by one thus populating the collection of ids on the client. Let me know if that helps.

Regards,
Tina Stancheva
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
Upload
Asked by
Evgeny
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or