Esempio n. 1
0
        public async Task <IActionResult> Index()
        {
            ViewBag.UserId = getClaimValue("Id");
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.UserViewModel> > >(Helpers.EscolaDeVoceEndpoints.User.create);

            return(View(response.data));
        }
        public async Task <IActionResult> Index()
        {
            //HttpContext.Session.SetString("", "Rick");
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.CourseViewModel> > >(Helpers.EscolaDeVoceEndpoints.Courses.getCourses + "/" + getClaimValue("Id"));

            return(View(response.data));
        }
        public async Task <bool> UpdateMedia()
        {
            var sambatechresponse = await ApiRequestHelper.Get <List <EscolaDeVoce.Services.ViewModel.VideoSambatech> >("http://api.sambavideos.sambatech.com/v1/medias?access_token=181e463a-034b-4ea5-878b-cea906a5f2e2&pid=6023");

            var videosResponse = _videoService.GetVideos(new Services.Message.GetVideosRequest());

            foreach (var m in sambatechresponse)
            {
                var video = videosResponse.videos.Where(v => v.sambatech_id == m.id).FirstOrDefault();

                if (video != null)
                {
                    video.thumbs       = new List <EscolaDeVoce.Services.ViewModel.ThumbViewModel>();
                    video.files        = new List <EscolaDeVoce.Services.ViewModel.FileViewModel>();
                    video.sambatech_id = m.id;
                    video.thumb        = m.thumbs[m.thumbs.Count - 1].url;
                    video.duration     = m.files[0].fileInfo.duration;

                    var updatevideoreques = new Services.Message.UpdateVideoRequest();
                    updatevideoreques.video = video;
                    var updateresponse = _videoService.UpdateVideo(updatevideoreques);
                }
            }

            return(true);
        }
        public async Task <IActionResult> Detalhe(string id)
        {
            ViewBag.image = getClaimValue("image");
            ViewBag.name  = getClaimValue(ClaimTypes.Name);
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.EscoleteTalkViewModel> >(Helpers.EscolaDeVoceEndpoints.EscoleTalk.get + "/" + id);

            return(View(response.data));
        }
        public async Task <IActionResult> Sala(string id, string videoid)
        {
            ViewBag.VideoId = Guid.Parse(videoid);
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> >(Helpers.EscolaDeVoceEndpoints.Courses.getdetail + "/" + id);

            var statusresponse = await ApiRequestHelper.Get <Infrastructure.ApiResponse <int> >(Helpers.EscolaDeVoceEndpoints.Videos.getStatus + "/" + getClaimValue("Id") + "/" + videoid);

            ViewBag.status = statusresponse.data;
            ViewBag.name   = getClaimValue(ClaimTypes.Name);
            return(View(response.data));
        }
Esempio n. 6
0
        public async Task <IActionResult> getMessages(string from)
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <Services.ViewModel.MessageViewModel> > >(Helpers.EscolaDeVoceEndpoints.Message.getusermessages + "/" + from + "/" + getClaimValue("Id").ToString());

            var retorno = new EscolaDeVoce.Frontend.UserMessages();

            retorno.mensagens = response.data;
            retorno.userid    = Guid.Parse(getClaimValue("Id"));

            return(PartialView("_ChatMessages", retorno));
        }
Esempio n. 7
0
        public async Task <IActionResult> Index()
        {
            var Id           = Guid.Parse(getClaimValue("Id"));
            var userresponse = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.UserViewModel> >(
                Helpers.EscolaDeVoceEndpoints.User.create + "/detail/" + Id,
                null,
                "token"
                );

            return(View(userresponse.data.person));
        }
Esempio n. 8
0
        public async Task <IActionResult> consultaCep(string cep)
        {
            //
            Frontend.Address           addressresponse = null;
            System.Net.Http.HttpMethod method          = System.Net.Http.HttpMethod.Put;
            addressresponse = await ApiRequestHelper.Get <Frontend.Address>(
                "https://viacep.com.br/ws/" + cep + "/json/",
                null
                );

            return(Json(addressresponse));
        }
Esempio n. 9
0
        public async Task <IViewComponentResult> InvokeAsync()
        {
            try
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.PersonalityQuestionViewModel> >(Helpers.EscolaDeVoceEndpoints.Questions.getNextQuestion + "/" + getClaimValue("Id").ToString());

                return(View(response.data));
            }
            catch (System.Exception)
            {
            }
            return(View(new EscolaDeVoce.Services.ViewModel.PersonalityQuestionViewModel()));
        }
        public async Task <IActionResult> Detail(string id)
        {
            Guid categoryid = Guid.Empty;

            if (Guid.TryParse(id, out categoryid))
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.ProjectViewModel> >(Helpers.EscolaDeVoceEndpoints.Project.getProjects + "/" + categoryid.ToString());

                return(View(response.data));
            }

            return(View());
        }
        public async Task <IViewComponentResult> InvokeAsync()
        {
            try
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.SchoolViewModel> > >(Helpers.EscolaDeVoceEndpoints.School.get);

                return(View(response.data));
            }
            catch (System.Exception)
            {
            }

            return(View(new List <EscolaDeVoce.Services.ViewModel.SchoolViewModel>()));
        }
        public async Task <IActionResult> Detalhe(string id)
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> >(Helpers.EscolaDeVoceEndpoints.Courses.getdetail + "/" + id + "/" + getClaimValue("Id"));

            if (response.data.userStarted)
            {
                var video = response.data.videos.FirstOrDefault();
                return(RedirectToAction("Sala", new { id = response.data.Id, videoid = video.Id }));
            }
            else
            {
                return(View(response.data));
            }
        }
Esempio n. 13
0
        public async Task <IViewComponentResult> InvokeAsync(Guid categoryid)
        {
            try
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.VideoViewModel> > >(Helpers.EscolaDeVoceEndpoints.Videos.getByCategory + categoryid.ToString());

                return(View(response.data));
            }
            catch (System.Exception)
            {
            }

            return(View(new List <EscolaDeVoce.Services.ViewModel.VideoViewModel>()));
        }
Esempio n. 14
0
        public async Task <IViewComponentResult> InvokeAsync(bool showEmbaixadorasButton)
        {
            ViewBag.showEmbaixadorasButton = showEmbaixadorasButton;
            try
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.EspecialistViewModel> > >(Helpers.EscolaDeVoceEndpoints.Especialist.getEspecialists);

                return(View(response.data));
            }
            catch (System.Exception)
            {
            }
            return(View(new List <EscolaDeVoce.Services.ViewModel.EspecialistViewModel>()));
        }
        public async Task <IViewComponentResult> InvokeAsync(string windowName, string buttonName)
        {
            ViewBag.windowName = windowName;
            ViewBag.buttonName = buttonName;
            try
            {
                var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.CourseViewModel> > >(Helpers.EscolaDeVoceEndpoints.Courses.getCourses);

                return(View(response.data));
            }
            catch (System.Exception)
            {
            }
            return(View(new List <EscolaDeVoce.Services.ViewModel.CourseViewModel>()));
        }
Esempio n. 16
0
        public async Task <IActionResult> Detail(string id)
        {
            if (id != null)
            {
                Guid schoolid = Guid.Empty;
                if (Guid.TryParse(id, out schoolid))
                {
                    var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.SchoolViewModel> >(Helpers.EscolaDeVoceEndpoints.School.get + "/" + schoolid.ToString());

                    return(View(response.data));
                }
            }

            return(View(new EscolaDeVoce.Services.ViewModel.SchoolViewModel()));
        }
        public async Task <IActionResult> SaveMedia([Bind("Id,name,url,views,order,sambatech_id,freeVideo,courseId,schoolId,categoriesId")] Services.ViewModel.VideoViewModel model)
        {
            var sambatechresponse = await ApiRequestHelper.Get <EscolaDeVoce.Backend.ViewModel.VideoSambatech>("http://api.sambavideos.sambatech.com/v1/medias/" + model.sambatech_id + "?access_token=181e463a-034b-4ea5-878b-cea906a5f2e2&pid=6023");

            EscolaDeVoce.Services.ViewModel.VideoViewModel response = null;
            model.thumbs = new List <EscolaDeVoce.Services.ViewModel.ThumbViewModel>();
            model.files  = new List <EscolaDeVoce.Services.ViewModel.FileViewModel>();

            foreach (var v in sambatechresponse.files)
            {
                EscolaDeVoce.Services.ViewModel.FileViewModel fl = new EscolaDeVoce.Services.ViewModel.FileViewModel();
                fl.fileName = v.fileName;
                fl.url      = v.url;
                fl.id       = v.id;
                model.files.Add(fl);
            }

            foreach (var th in sambatechresponse.thumbs)
            {
                EscolaDeVoce.Services.ViewModel.ThumbViewModel thumb = new EscolaDeVoce.Services.ViewModel.ThumbViewModel();
                thumb.height = th.height;
                thumb.width  = th.width;
                thumb.url    = th.url;
                model.thumbs.Add(thumb);
            }

            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;

            response = await ApiRequestHelper.postPutRequest <EscolaDeVoce.Services.ViewModel.VideoViewModel>(
                Helpers.EscolaDeVoceEndpoints.Videos.video,
                method,
                JsonConvert.SerializeObject(model)
                );

            return(View());
        }
        public async Task <IActionResult> Index()
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <EscolaDeVoce.Services.ViewModel.ProjectViewModel> > >(Helpers.EscolaDeVoceEndpoints.Project.getProjects);

            return(View(response.data));
        }
Esempio n. 19
0
        public async Task <IActionResult> getUsers(string search)
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <List <Services.ViewModel.UserViewModel> > >(Helpers.EscolaDeVoceEndpoints.User.create + "?search=" + search);

            return(PartialView("_UserChat", response.data));
        }
Esempio n. 20
0
        public async Task <IActionResult> Login(string username, string password, bool isFacebook)
        {
            Frontend.AuthenticationModel response = null;
            response = await ApiRequestHelper.postPutEncodedRequest <AuthenticationModel>(
                Helpers.EscolaDeVoceEndpoints.tokenUrl,
                username,
                password,
                isFacebook
                );

            if (response != null)
            {
                if (response.StatusCode != HttpStatusCode.Created)
                {
                    return(Json(new {
                        status = false
                    }));
                }
                Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.UserViewModel> userresponse = null;

                userresponse = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.UserViewModel> >(
                    Helpers.EscolaDeVoceEndpoints.User.info,
                    null,
                    response.access_token
                    );

                const string Issuer = "https://www.escoladevoce.com.br";
                var          claims = new List <Claim> {
                    new Claim(ClaimTypes.Name, userresponse.data.person.name, ClaimValueTypes.String, Issuer),
                    new Claim("Id", userresponse.data.Id.ToString(), ClaimValueTypes.String, Issuer),
                    new Claim(ClaimTypes.Email, userresponse.data.username, ClaimValueTypes.String, Issuer),
                    new Claim("TOKEN", response.access_token, ClaimValueTypes.String, Issuer),
                };

                var userIdentity = new ClaimsIdentity(claims, "Passport");

                if (!String.IsNullOrEmpty(userresponse.data.cover))
                {
                    userIdentity.AddClaim(new Claim("cover", userresponse.data.cover, ClaimValueTypes.String, Issuer));
                }
                if (!String.IsNullOrEmpty(userresponse.data.image))
                {
                    userIdentity.AddClaim(new Claim("image", userresponse.data.image, ClaimValueTypes.String, Issuer));
                }

                var userPrincipal = new ClaimsPrincipal(userIdentity);

                await HttpContext.Authentication.SignInAsync("Cookie", userPrincipal,
                                                             new AuthenticationProperties
                {
                    ExpiresUtc   = DateTime.UtcNow.AddMinutes(30),
                    IsPersistent = true,
                    AllowRefresh = false
                });

                return(Json(new {
                    status = true
                }));
            }

            return(Json(new {
                status = false
            }));
        }
Esempio n. 21
0
        public async Task <IActionResult> getNextQuestion(string from)
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <Services.ViewModel.PersonalityQuestionViewModel> >(Helpers.EscolaDeVoceEndpoints.User.nextQuestion + "/" + getClaimValue("Id").ToString());

            return(PartialView("_QuizQuestion", response.data));
        }
        public async Task <IActionResult> Detalhes(string id)
        {
            var response = await ApiRequestHelper.Get <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> >(Helpers.EscolaDeVoceEndpoints.Courses.getdetail + "/" + id + "/" + getClaimValue("Id"));

            return(View(response.data));
        }