Example #1
0
        public async Task <string> AddPetAsync(string pathf, Stream f, Pet pet)
        {
            if (String.IsNullOrEmpty(pet.Name) || String.IsNullOrEmpty(pet.PetType))
            {
                return(English.YouHaveToFillAllEntries());
            }
            else if (pet.Age < 0)
            {
                return(English.NotNegNumber());
            }
            else if (!String.IsNullOrEmpty(pathf))
            {
                string uniqueBlobName = await DependencyService.Get <IBlobStorage.IBlobStorage>().UploadFileAsync(pathf, f);

                uniqueBlobName = GlobalVariables.blobstorageurl + uniqueBlobName;

                pet.ProfilePictureURL = uniqueBlobName;
            }
            else
            {
                pet.ProfilePictureURL = "";
            }

            pet.Uploader = GlobalVariables.ActualUser.id;

            int success = DependencyService.Get <IDBAccess.IBlobStorage>().InsertPet(pet);

            if (success == -1)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                pet.id = success;

                var myPetList = GlobalVariables.ConvertPetToMyPetList(pet);

                GlobalVariables.Mypetlist.Add(myPetList);

                GlobalVariables.MyPetsString.Add(myPetList.Name);

                //GlobalVariables.SetMyPetListString();

                GlobalVariables.AddedPet = true;

                //GlobalVariables.LocalSQLiteDatabase.InsertMyPetsList(myPetList);

                return(English.Empty());
            }
        }
Example #2
0
        public string AddPetAsync(bool addedPhoto, Stream f, Pet pet)
        {
            if (string.IsNullOrEmpty(pet.Name) || string.IsNullOrEmpty(pet.PetType))
            {
                return(English.YouHaveToFillAllEntries());
            }
            else if (addedPhoto)
            {
                pet.Profilepicture = new Segédfüggvények().ReadFully(f);
            }
            else
            {
                pet.Profilepicture = null;
            }

            pet.Uploader = GlobalVariables.ActualUser.id;

            int success = GlobalVariables.databaseConnection.AddPet(pet);

            if (success == -1)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                pet.id = success;

                var myPetList = GlobalVariables.ConvertPetToMyPetList(pet);

                GlobalVariables.Mypetlist.Add(myPetList);

                GlobalVariables.MyPetsString.Add(myPetList.Name);

                GlobalVariables.AddedPet = true;

                return(English.Empty());
            }
        }