public async void saveOutfit(object sender, EventArgs e)
        {
            string outfitName = await DisplayPromptAsync("Outfit Name", "Outfit Name");

            string imageStringPant  = imageToBase64(imagePathPant);
            string imageStringShirt = imageToBase64(imagePathShirt);
            Cloth  clothPant        = new Cloth(user.userId, imageStringPant);
            Cloth  newPant          = await clothController.createCloth(clothPant);

            Cloth clothShirt = new Cloth(user.userId, imageStringShirt);
            Cloth newShirt   = await clothController.createCloth(clothShirt);

            Outfit outfitShirt = new Outfit(user.userId, outfitName, newShirt.clothId);
            Outfit outfitPant  = new Outfit(user.userId, outfitName, newPant.clothId);
            bool   flag        = await outfitController.createModel(outfitShirt);

            if (flag)
            {
                flag = await outfitController.createModel(outfitPant);

                if (flag)
                {
                    await DisplayAlert("Message", "Outfit Created!", "Okay");
                }
            }
            else
            {
                await DisplayAlert("Message", "Outfit Creation Failed!", "Okay");
            }
        }
Exemplo n.º 2
0
        public async void createPost(object sender, EventArgs e) // creation of a new post with required fields
        {
            try
            {
                string todayDate   = DateTime.Now.ToString("yyyy-MM-dd");
                string imageString = imageToBase64();
                Cloth  cloth       = new Cloth(user.userId, pickerCLothType.SelectedItem.ToString(), imageString, entryColor.Text, entryMaterial.Text, pickerSeason.SelectedItem.ToString());
                Cloth  newCloth    = await clothController.createCloth(cloth);

                if (newCloth != null)
                {
                    Post post    = new Post(user.userId, newCloth.clothId, Double.Parse(entryPrice.Text), entryUrl.Text, switchModel.IsToggled);
                    Post newPost = await postController.createPost(post);

                    if (newPost != null)
                    {
                        PostRecord postRecord = new PostRecord(user.userId, newPost.postId, todayDate);

                        bool flag = await postRecordController.createModel(postRecord);

                        if (flag)
                        {
                            await DisplayAlert("Message", "Post Create Successfully!", "Okay");

                            App.Current.MainPage = new NavPage(user);
                        }

                        else
                        {
                            await DisplayAlert("Message", "Error Occured!", "Okay");
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }