public async System.Threading.Tasks.Task <string> UploadPictureAsync(string pathf, Stream f, int petid, string hashtag) { if (petid == -1) { return(English.ChooseAnimal()); } if (!String.IsNullOrEmpty(pathf)) { string uniqueBlobName = await DependencyService.Get <IBlobStorage.IBlobStorage>().UploadFileAsync(pathf, f); uniqueBlobName = GlobalVariables.blobstorageurl + uniqueBlobName; Petpictures petpictures = new Petpictures() { PetID = petid, PictureURL = uniqueBlobName, UploadDate = DateTime.UtcNow.ToString("") }; int success = DependencyService.Get <IDBAccess.IBlobStorage>().InsertPetpictures(petpictures); if (success == -1) { return(English.SomethingWentWrong()); } else { if (!String.IsNullOrEmpty(hashtag)) { var hashtags = hashtag.Trim().Split('#'); bool uploadedHashtag = true; foreach (var item in hashtags) { if (!string.IsNullOrEmpty(item)) { Hashtags ahashtag = new Hashtags(); ahashtag.hashtag = item.Replace(" ", string.Empty); ahashtag.petpicturesid = success; uploadedHashtag = DependencyService.Get <IDBAccess.IBlobStorage>().InsertHashtags(ahashtag); if (!uploadedHashtag) { return(English.SomethingWentWrong()); } } } } return(English.Empty()); } } else { return(English.ChooseAPicture()); } }
public string UploadPictureAsync(bool addedPhoto, Stream f, int petid, string hashtag) { if (petid == -1) { return(English.ChooseAnimal()); } if (addedPhoto) { Petpictures petpictures = new Petpictures() { PetID = petid, PictureURL = new Segédfüggvények().ReadFully(f), UploadDate = DateTime.UtcNow.ToString("") }; int success = GlobalVariables.databaseConnection.UploadPhoto(petpictures); if (success == -1) { return(English.SomethingWentWrong()); } else { if (!string.IsNullOrEmpty(hashtag)) { var hashtags = hashtag.Trim().Split('#'); bool uploadedHashtag = true; foreach (var item in hashtags) { if (!string.IsNullOrEmpty(item)) { Hashtags ahashtag = new Hashtags(); ahashtag.hashtag = item.Replace(" ", string.Empty); ahashtag.petpicturesid = success; uploadedHashtag = GlobalVariables.databaseConnection.InsertHashtags(ahashtag); if (!uploadedHashtag) { return(English.SomethingWentWrong()); } } } } return(English.Empty()); } } else { return(English.ChooseAPicture()); } }