public async Task <string> SignUpAsync(User user)
        {
            if (string.IsNullOrEmpty(user.Email) || string.IsNullOrEmpty(user.FirstName) ||
                string.IsNullOrEmpty(user.LastName) || string.IsNullOrEmpty(user.Password))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (user.Password.Length < 6 || user.Password.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            user.Email = user.Email.ToLower();

            var isItAUser = GlobalVariables.databaseConnection.GetUserByEmail(user.Email);

            if (isItAUser is null || string.IsNullOrEmpty(isItAUser.Email))
            {
                GlobalVariables.InitializeGlobalCasualImage();

                user.ProfilePicture = GlobalVariables.GlobalCasualImage;
                user.Password       = new Segédfüggvények().EncryptPassword(user.Password);

                var success = GlobalVariables.databaseConnection.AddUser(user);

                if (success)
                {
                    return(English.Empty());
                }
            }
        public string DeleteAccount()
        {
            int i = 0;

            if (GlobalVariables.Mypetlist.Count != 0)
            {
                while (GlobalVariables.Mypetlist.Count != 0)
                {
                    string siker = GlobalVariables.updatePetFragmentViewModel.DeletePet(GlobalVariables.Mypetlist[i].petid);

                    if (!string.IsNullOrEmpty(siker))
                    {
                        return(English.SomethingWentWrong());
                    }

                    i++;
                }
            }

            GlobalVariables.Mypetlist = new System.Collections.Generic.List <GlobalVariables.MyPetsList>();

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().DeleteAccount(GlobalVariables.ActualUser.id);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                return(English.Empty());
            }
        }
        //1:üres mind a kettő
        //2:első üres
        //3:második üres
        //4:nem jó az email formátuma
        //5:a pw nem olyan hosszban van 6-16
        //6:nem található ilyen email a DBben vagy rossz a jelszó
        //7:minden jó
        public string Login(string EMAIL, string PASSWORD)
        {
            if (String.IsNullOrEmpty(EMAIL) && String.IsNullOrEmpty(PASSWORD))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (String.IsNullOrEmpty(EMAIL))
            {
                return(English.EmailIsEmpty());
            }
            if (String.IsNullOrEmpty(PASSWORD))
            {
                return(English.PasswordIsEmpty());
            }
            if (!segédfüggvények.IsValidEmailAddress(EMAIL.ToLower()))
            {
                return(English.BadEmailFormat());
            }
            if (PASSWORD.Length < 6 || PASSWORD.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            var user = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(EMAIL.ToLower());

            if (user is null || user.Password != PASSWORD)
            {
                return(English.BadPasswordOrEmail());
            }

            return(English.Empty());
        }
        //1:üres mind a kettő
        //2:első üres
        //3:második üres
        //4:nem jó az email formátuma
        //5:a pw nem olyan hosszban van 6-16
        //6:nem található ilyen email a DBben vagy rossz a jelszó
        //7:minden jó
        public string Login(string EMAIL, string PASSWORD)
        {
            if (String.IsNullOrEmpty(EMAIL) && String.IsNullOrEmpty(PASSWORD))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (String.IsNullOrEmpty(EMAIL))
            {
                return(English.EmailIsEmpty());
            }
            if (String.IsNullOrEmpty(PASSWORD))
            {
                return(English.PasswordIsEmpty());
            }
            if (!segédfüggvények.IsValidEmailAddress(EMAIL.ToLower()))
            {
                return(English.BadEmailFormat());
            }
            if (PASSWORD.Length < 6 || PASSWORD.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            var user = GlobalVariables.databaseConnection.GetUserByEmail(EMAIL.ToLower());

            if (user is null || user.Password != segédfüggvények.EncryptPassword(PASSWORD))
            {
                return(English.BadPasswordOrEmail());
            }

            return(English.Empty());
        }
예제 #5
0
        public string UpdatePetProfile(Pet pet)
        {
            bool success = GlobalVariables.databaseConnection.UpdatePet(pet.id, pet);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                int i = 0;

                foreach (var item in GlobalVariables.Mypetlist)
                {
                    if (item.petid == pet.id)
                    {
                        GlobalVariables.Mypetlist[i].PetType     = pet.PetType;
                        GlobalVariables.Mypetlist[i].Age         = pet.Age;
                        GlobalVariables.Mypetlist[i].HaveAnOwner = pet.HaveAnOwner;
                        GlobalVariables.Mypetlist[i].Name        = pet.Name;

                        GlobalVariables.MyPetsString[i] = pet.Name;

                        break;
                    }

                    i++;
                }

                GlobalVariables.AddedPet = true;

                return(English.Empty());
            }
        }
        public string DeleteAccount()
        {
            int i = 0;

            if (GlobalVariables.Mypetlist.Count != 0)
            {
                while (GlobalVariables.Mypetlist.Count != 0)
                {
                    if (!string.IsNullOrEmpty(GlobalVariables.updatePetFragmentViewModel.DeletePet(GlobalVariables.Mypetlist[i].petid)))
                    {
                        return(English.SomethingWentWrong());
                    }

                    i++;
                }
            }

            GlobalVariables.Mypetlist = new System.Collections.Generic.List <MyPetsList>();

            if (!GlobalVariables.databaseConnection.DeleteAccount(GlobalVariables.ActualUser.id))
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                return(English.Empty());
            }
        }
        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 UpdatePetProfile(Pet pet)
        {
            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().UpdatePet(pet.id, pet);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                int i = 0;

                foreach (var item in GlobalVariables.Mypetlist)
                {
                    if (item.petid == pet.id)
                    {
                        GlobalVariables.Mypetlist[i].PetType     = pet.PetType;
                        GlobalVariables.Mypetlist[i].Age         = pet.Age;
                        GlobalVariables.Mypetlist[i].HaveAnOwner = pet.HaveAnOwner;
                        GlobalVariables.Mypetlist[i].Name        = pet.Name;

                        GlobalVariables.MyPetsString[i] = pet.Name;

                        break;
                    }

                    i++;
                }

                GlobalVariables.AddedPet = true;

                return(English.Empty());
            }
        }
        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());
            }
        }
예제 #10
0
        private string UpdateUser(User user)
        {
            if (GlobalVariables.databaseConnection.UpdateUser(user.id, user))
            {
                GlobalVariables.ActualUser = user;

                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
예제 #11
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());
            }
        }
예제 #12
0
        private string UpdateUser(User user)
        {
            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().UpdateUser(user.id, user);

            if (success)
            {
                GlobalVariables.ActualUser = user;

                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
예제 #13
0
        public string UnFollow(string userEmail, int petid)
        {
            int userid = GlobalVariables.databaseConnection.GetUserByEmail(userEmail).id;

            bool success = GlobalVariables.databaseConnection.DeleteFollowing(userid, petid);

            if (success)
            {
                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
        public string UnFollow(string userEmail, int petid)
        {
            int userid = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(userEmail).id;

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().DeleteFollowing(userid, petid);

            if (success)
            {
                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
        public string DeletePet(int petid)
        {
            var petpictureList = DependencyService.Get <IDBAccess.IBlobStorage>().GetPetpictureByID(petid);

            foreach (var item in petpictureList)
            {
                bool successD = GlobalVariables.seePictureFragmentViewModel.DeletePicture(item);

                if (!successD)
                {
                    return(English.SomethingWentWrong());
                }
            }

            Pet pet = GlobalVariables.ConvertMyPetListToPet(GlobalVariables.Mypetlist.Where(i => i.petid == petid).FirstOrDefault());

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().DeletePet(pet);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                int i = 0;

                foreach (var item in GlobalVariables.Mypetlist)
                {
                    if (item.petid == petid)
                    {
                        GlobalVariables.Mypetlist.RemoveAt(i);
                        GlobalVariables.MyPetsString.RemoveAt(i);

                        break;
                    }

                    i++;
                }

                GlobalVariables.AddedPet = true;

                return(English.Empty());
            }
        }
        public string UnLikeClick(int petpicturesid)
        {
            Likes likes = new Likes()
            {
                UserID        = GlobalVariables.ActualUser.id,
                Petpicturesid = petpicturesid
            };

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().DeleteLikesNotByParam(likes);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                return(English.Empty());
            }
        }
        public string LikePicture(int petpicturesid)
        {
            Likes likes = new Likes()
            {
                UserID        = GlobalVariables.ActualUser.id,
                Petpicturesid = petpicturesid
            };

            bool success = GlobalVariables.databaseConnection.InsertLikes(likes);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                return(English.Empty());
            }
        }
예제 #18
0
        public string UnLikeClick(int petpicturesid)
        {
            Likes likes = new Likes()
            {
                UserID        = GlobalVariables.ActualUser.id,
                Petpicturesid = petpicturesid
            };

            bool success = GlobalVariables.databaseConnection.DeleteLikesNotByParam(likes);

            if (!success)
            {
                return(English.SomethingWentWrong());
            }
            else
            {
                return(English.Empty());
            }
        }
        public async Task <string> UpdatePetProfilePictureAsync(Pet pet, Stream stream, string uri)
        {
            if (!String.IsNullOrEmpty(uri))
            {
                string uniqueBlobName = await DependencyService.Get <IBlobStorage.IBlobStorage>().UploadFileAsync(uri, stream);

                uniqueBlobName = GlobalVariables.blobstorageurl + uniqueBlobName;

                pet.ProfilePictureURL = uniqueBlobName;

                bool success = DependencyService.Get <IDBAccess.IBlobStorage>().UpdatePet(pet.id, pet);

                if (!success)
                {
                    return(English.SomethingWentWrong());
                }
                else
                {
                    int i = 0;

                    foreach (var item in GlobalVariables.Mypetlist)
                    {
                        if (item.petid == pet.id)
                        {
                            GlobalVariables.Mypetlist[i].ProfilePictureURL = pet.ProfilePictureURL;

                            break;
                        }

                        i++;
                    }

                    GlobalVariables.AddedPet = true;

                    return(English.Empty());
                }
            }
            else
            {
                return(English.Empty());
            }
        }
예제 #20
0
        public string FollowAPet(string userEmail, int petid)
        {
            int userid = GlobalVariables.databaseConnection.GetUserByEmail(userEmail).id;

            Following following = new Following()
            {
                FUserID = petid,
                UserID  = userid
            };

            bool success = GlobalVariables.databaseConnection.InsertFollowing(following);

            if (success)
            {
                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
        public string FollowAPet(string userEmail, int petid)
        {
            int userid = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(userEmail).id;

            Following following = new Following()
            {
                FUserID = petid,
                UserID  = userid
            };

            bool success = DependencyService.Get <IDBAccess.IBlobStorage>().InsertFollowing(following);

            if (success)
            {
                return(English.Empty());
            }
            else
            {
                return(English.SomethingWentWrong());
            }
        }
예제 #22
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());
            }
        }
        public async Task <string> SignUpAsync(User user)
        {
            if (String.IsNullOrEmpty(user.Email) || String.IsNullOrEmpty(user.FirstName) ||
                String.IsNullOrEmpty(user.LastName) || String.IsNullOrEmpty(user.Password))
            {
                return(English.YouHaveToFillAllEntries());
            }
            if (user.Password.Length < 6 && user.Password.Length > 16)
            {
                return(English.BadPasswordLength());
            }

            user.Email = user.Email.ToLower();

            var isItAUser = DependencyService.Get <IDBAccess.IBlobStorage>().GetUserByEmail(user.Email);

            if (isItAUser.Email is null)
            {
                var success = DependencyService.Get <IDBAccess.IBlobStorage>().InsertUser(user);

                if (success)
                {
                    string         url     = String.Format("http://petbellies.com/php/petbelliesreg.php?email={0}&nev={1}", user.Email, user.FirstName);
                    Uri            uri     = new Uri(url);
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
                    request.Method = "GET";
                    WebResponse res = await request.GetResponseAsync();

                    return(English.Empty());
                }
            }
            else
            {
                return(English.ThisEmailIsExist());
            }

            return(English.SomethingWentWrong());
        }
예제 #24
0
        public string UpdatePetProfilePictureAsync(bool addedPhoto, Pet pet, Stream f)
        {
            if (addedPhoto)
            {
                pet.Profilepicture = new Segédfüggvények().ReadFully(f);

                if (!GlobalVariables.databaseConnection.UpdatePet(pet.id, pet))
                {
                    return(English.SomethingWentWrong());
                }
                else
                {
                    int i = 0;

                    foreach (var item in GlobalVariables.Mypetlist)
                    {
                        if (item.petid == pet.id)
                        {
                            GlobalVariables.Mypetlist[i].ProfilePictureURL = pet.Profilepicture;

                            break;
                        }

                        i++;
                    }

                    GlobalVariables.AddedPet = true;

                    return(English.Empty());
                }
            }
            else
            {
                return(English.Empty());
            }
        }