Exemple #1
0
        public async void SendMedia(string filePath, string mediaType)
        {
            BTProgressHUD.Show("Please Wait", maskType: ProgressHUD.MaskType.Black);
            var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType);
            var url       = "";

            try
            {
                // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black);
                if (mediaType == "Photo")
                {
                    await AWSUploader.AWSUploadImage(filePath, mediaName);
                }
                else
                {
                    await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType);
                }
                url = AWSUploader.GetMediaUrl(mediaType) + mediaName;



                try
                {
                    if (string.IsNullOrEmpty(url))
                    {
                        // AlertBox.Create("Upload", "File upload failed, Please check your internet connection", null);

                        return;
                    }
                    else
                    {
                        lstAttachments = new List <AttachmentViewModel>();
                        var attachment = new AttachmentViewModel();
                        attachment.Type = mediaType;
                        attachment.Url  = url;
                        lstAttachments.Add(attachment);

                        SendThumbMedia(thumbFilePath, mediaType);
                        //BTProgressHUD.Dismiss();
                        //ButtonSendChatMessage();
                    }
                }
                catch (Exception e)
                {
                    // Crashes.TrackError(e);
                }
            }
            catch (Exception e)
            {
                // Crashes.TrackError(e);
            }
        }
        private async void uploadMedia(string filePath, string mediaType)
        {
            var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType);
            var url       = "";

            try
            {
                // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black);
                if (mediaType == "Photo")
                {
                    await AWSUploader.AWSUploadImage(filePath, mediaName);
                }
                else
                {
                    await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType);
                }
                url = AWSUploader.GetMediaUrl(mediaType) + mediaName;


                try
                {
                    if (string.IsNullOrEmpty(url))
                    {
                        Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show();
                    }
                    else
                    {
                        var model = new GroupRequestViewModel
                        {
                            Name        = txtGroupName.Text,
                            Description = txtGroupDesc.Text,
                            GroupType   = (GroupType)grouptype,
                            InterestId  = Convert.ToInt32(drpInterestList[drpInterest.SelectedItemPosition].Value),
                            IsPrivate   = privategroup.Checked,
                            PictureUrl  = url
                        };
                        Intent intent = new Intent(this, typeof(SelectGroupContactActivity));
                        intent.PutExtra("GroupObject", JsonConvert.SerializeObject(model));
                        StartActivity(intent);
                    }
                }
                catch (Java.Lang.Exception e)
                {
                    Toast.MakeText(this, e.Message, ToastLength.Long).Show();
                }
            }
            catch (Java.Lang.Exception e)
            {
                Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }
        }
Exemple #3
0
        public async Task <ActionResult> AddGameView(GameViewModel gameViewModel)
        {
            if (ModelState.IsValid)
            {
                /*var f = Request.Files;
                 * System.Diagnostics.Debug.WriteLine(f.Count);
                 * if (f == null)
                 * {
                 *  System.Diagnostics.Debug.WriteLine(gameViewModel.game.GameName);
                 *  System.Diagnostics.Debug.WriteLine("input file is null");
                 * }*/
                if (gameViewModel.InputFile.ContentLength > 0)
                {
                    System.Diagnostics.Debug.WriteLine("input file is in viewmodel");
                    AWSUploader myUploader = new AWSUploader();
                    //if (Request.Files.Count > 0)

                    Stream fs     = gameViewModel.InputFile.InputStream;
                    String s3Name = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + gameViewModel.game.GameName;
                    System.Diagnostics.Debug.WriteLine(s3Name);
                    bool a = myUploader.sendMyFileToS3(fs, "gearstore", s3Name);
                    GetPreSignedUrlRequest request1 = new GetPreSignedUrlRequest
                    {
                        BucketName = bucketName,
                        Key        = s3Name,
                        Expires    = DateTime.Now.AddYears(10)
                    };
                    String urlString = s3Client.GetPreSignedURL(request1);
                    gameViewModel.game.GameSnapshotLink = urlString;
                    using (var client = new HttpClient())
                    {
                        client.BaseAddress = new Uri("https://gearstorefixurl.azurewebsites.net/api/Games");
                        var postTask = client.PostAsJsonAsync <Game>("Games", gameViewModel.game);

                        postTask.Wait();

                        var postresult = postTask.Result;
                        System.Diagnostics.Debug.WriteLine(postresult);
                        if (postresult.IsSuccessStatusCode)
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                }
            }
            return(View());
        }
Exemple #4
0
        private async void uploadMedia(string filePath, string mediaType, GroupRequestViewModel model)
        {
            var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType);
            var url       = "";

            try
            {
                // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black);
                if (mediaType == "Photo")
                {
                    await AWSUploader.AWSUploadImage(filePath, mediaName);
                }
                else
                {
                    await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType);
                }
                url = AWSUploader.GetMediaUrl(mediaType) + mediaName;


                try
                {
                    if (string.IsNullOrEmpty(url))
                    {
                        //Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show();
                    }
                    else
                    {
                        GroupRequestViewModel groupRequestViewModel = new GroupRequestViewModel();
                        groupRequestViewModel = new GroupRequestViewModel
                        {
                            Name        = txtGroupName.Text,
                            Description = txtDescription.Text,
                            GroupType   = (GroupType)grouptype,
                            InterestId  = interestID,
                            IsPrivate   = privategroup,
                            PictureUrl  = url
                        };
                        BTProgressHUD.Dismiss();

                        InvokeOnMainThread(delegate
                        {
                            var viewController        = (SelectGroupContactViewController)Storyboard.InstantiateViewController("SelectGroupContactViewController");
                            viewController.groupmodel = groupRequestViewModel;
                            NavigationController.PushViewController(viewController, true);
                        });
                    }
                }
                catch (Exception e)
                {
                    Crashes.TrackError(e);
                    BTProgressHUD.Dismiss();
                    new UIAlertView("Error", e.ToString(), null, "OK", null).Show();
                    //Toast.MakeText(this, e.Message, ToastLength.Long).Show();
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
                BTProgressHUD.Dismiss();
                new UIAlertView("Error", e.ToString(), null, "OK", null).Show();
                //Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }
        }
        private async void uploadMedia(string filePath, string mediaType, UserRegisterResponseViewModel model)
        {
            var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType);
            var url       = "";

            try
            {
                // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black);
                if (mediaType == "Photo")
                {
                    await AWSUploader.AWSUploadImage(filePath, mediaName);
                }
                else
                {
                    await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType);
                }
                url = AWSUploader.GetMediaUrl(mediaType) + mediaName;


                try
                {
                    if (string.IsNullOrEmpty(url))
                    {
                        //Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show();
                    }
                    else
                    {
                        var Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                        {
                            Email    = model.Email,
                            Password = model.Password,

                            ZipCode         = model.ZipCode,
                            City            = model.City,
                            State           = model.State,
                            Country         = model.Country,
                            AboutMe         = model.AboutMe,
                            ProfileImageUrl = url,
                        }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                        if (Result.Status == 1)
                        {
                            var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());

                            var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());
                            UserprofileRepo.ZipCode = modelReporeg.ZipCode;
                            UserprofileRepo.City    = modelReporeg.City;
                            UserprofileRepo.State   = modelReporeg.State;
                            UserprofileRepo.Country = modelReporeg.Country;

                            UserprofileRepo.AboutMe         = modelReporeg.AboutMe;
                            UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl;



                            UserProfileRepository.UpdateUserProfile(UserprofileRepo);
                            new UIAlertView("Update Your Profile", "Profile Updated Successfully", null, "OK", null).Show();

                            BTProgressHUD.Dismiss();
                            this.DismissViewController(true, null);
                        }
                    }
                }
                catch (Exception e)
                {
                    Crashes.TrackError(e);
                    BTProgressHUD.Dismiss();
                    new UIAlertView("Error", e.ToString(), null, "OK", null).Show();
                    //Toast.MakeText(this, e.Message, ToastLength.Long).Show();
                }
            }
            catch (Exception e)
            {
                Crashes.TrackError(e);
                BTProgressHUD.Dismiss();
                new UIAlertView("Error", e.ToString(), null, "OK", null).Show();
                //Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }
        }
Exemple #6
0
        private async void uploadMedia(string filePath, string mediaType, UserRegisterResponseViewModel model)
        {
            var mediaName = System.IO.Path.GetFileName(filePath); //AWSUploader.SetMediaName (mediaType);
            var url       = "";

            try
            {
                // BTProgressHUD.Show("Processing media..", maskType: ProgressHUD.MaskType.Black);
                if (mediaType == "Photo")
                {
                    await AWSUploader.AWSUploadImage(filePath, mediaName);
                }
                else
                {
                    await AWSUploader.AWSUploadAudioVideo(filePath, mediaName, mediaType);
                }
                url = AWSUploader.GetMediaUrl(mediaType) + mediaName;


                try
                {
                    if (string.IsNullOrEmpty(url))
                    {
                        Toast.MakeText(this, "Check Your Internet Connection", ToastLength.Long).Show();
                    }
                    else
                    {
                        var Result = await new AccountService().Registration(new UserRegisterRequestViewModel
                        {
                            Email    = model.Email,
                            Password = model.Password,

                            ZipCode         = model.ZipCode,
                            City            = model.City,
                            State           = model.State,
                            Country         = model.Country,
                            AboutMe         = model.AboutMe,
                            ProfileImageUrl = url,
                        }, GlobalConstant.AccountUrls.RegisterServiceUrl);

                        if (Result.Status == 1)
                        {
                            var modelReporeg = JsonConvert.DeserializeObject <UserRegisterResponseViewModel>(Result.Response.ToString());

                            var UserprofileRepo = UserProfileRepository.GetUserProfile(CommonHelper.GetUserId());
                            UserprofileRepo.ZipCode = modelReporeg.ZipCode;
                            UserprofileRepo.City    = modelReporeg.City;
                            UserprofileRepo.State   = modelReporeg.State;
                            UserprofileRepo.Country = modelReporeg.Country;

                            UserprofileRepo.AboutMe         = modelReporeg.AboutMe;
                            UserprofileRepo.ProfileImageUrl = modelReporeg.ProfileImageUrl;



                            UserProfileRepository.UpdateUserProfile(UserprofileRepo);
                            Toast.MakeText(this, "Profile Complete Successfully", ToastLength.Short).Show();
                            CommonHelper.DismissProgressBar(this);
                            this.Finish();
                            var intent = new Intent(this, typeof(MainActivity));
                            intent.AddFlags(ActivityFlags.SingleTop);

                            StartActivity(intent);
                        }
                    }
                }
                catch (Java.Lang.Exception e)
                {
                    Toast.MakeText(this, e.Message, ToastLength.Long).Show();
                }
            }
            catch (Java.Lang.Exception e)
            {
                Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }
        }