Hi Friends, I am working on a website, where user can upload photos of product they want to advertise. I am saving photos in a folder on the web. In the table where I keep reference of photos, there is a key field photoid which is Identity field(primary key).
My repository has following methods
Photo photo = rep.NewPhoto();
photo.Title="Some Title";
rep.InsertPhoto(photo);
rep.SaveAll();
rep.SavePhoto(photo,uploadedPhoto);
rep.SaveAll();
I am using Linq to SQL for my data model. Now my problem is, if I want to save my files with a name which is coming from photoid, I have to Call the rep.SaveAll() method to get the new created photoid and then save the photo with new id and then I have to Call SaveAll() method to update it again with the changes happend in SavePhoto() method.
Other option is I save the file with some random file number first and then Save the photo record in one step.
This is second approach.
Photo photo = rep.NewPhoto();
photo.Title="Some Title";
string filename = rep.SavePhoto(uploadedPhoto);
photo.FileName=filename;
rep.InsertPhoto(photo);
rep.SaveAll();
Saving files with photoid has one good point, photos can be easily loaded using its id.
What is a good approach to achieve this kind of functionality.
Help will be appritiate.
Cheers Parminder