public ActionResult Delete(int photoItemID)
{
_mu = MembershipWrapper.GetUser();
_pitm = new PhotoItem(photoItemID);
if (_mu == null || _pitm.CreatedByUserID != Convert.ToInt32(_mu.ProviderUserKey))
return RedirectToAction("Index");
var s3 = new S3Service
{
AccessKeyID = AmazonCloudConfigs.AmazonAccessKey,
SecretAccessKey = AmazonCloudConfigs.AmazonSecretKey
};
_pitm.Delete();
if (string.IsNullOrEmpty(_pitm.FilePathStandard)) return RedirectToAction("Index");
// delete the existing photos
try
{
if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathStandard))
{
s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathStandard);
}
if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathRaw))
{
s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathRaw);
}
if (s3.ObjectExists(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathThumb))
{
s3.DeleteObject(AmazonCloudConfigs.AmazonBucketName, _pitm.FilePathThumb);
}
}
catch
{
// whatever
}
return RedirectToAction("Index");
}