Exemple #1
0
        public async Task <IActionResult> Detail([Bind("Id,name")] Services.ViewModel.CategoryViewModel model)
        {
            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CategoryViewModel> response = null;

            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            var url = Helpers.EscolaDeVoceEndpoints.Category.getCategories;

            if (model.Id != Guid.Empty)
            {
                method = System.Net.Http.HttpMethod.Put;
                url    = Helpers.EscolaDeVoceEndpoints.Category.getCategories + "/" + model.Id.ToString();
            }


            response = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CategoryViewModel> >(
                url,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (model.Id != Guid.Empty || (response.data != null && response.data.Id != Guid.Empty))
            {
                var Id = model.Id != Guid.Empty ? model.Id : response.data.Id;
                return(RedirectToAction("Detail", new { id = Id.ToString() }));
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> AddToFavorite(string videoId)
        {
            var model = new EscolaDeVoce.Services.ViewModel.AddVideoToFavoriteViewModel();

            model.userId  = Guid.Parse(getClaimValue("Id"));
            model.videoId = Guid.Parse(videoId);

            Infrastructure.ApiResponse <bool> favoriteresponse = null;
            System.Net.Http.HttpMethod        method           = System.Net.Http.HttpMethod.Post;
            favoriteresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Videos.addToFavorites,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (favoriteresponse != null)
            {
                return(Json(new {
                    success = true
                }));
            }

            return(Json(new {
                success = false
            }));
        }
        public async Task <IActionResult> SaveComment(string id, string comment)
        {
            var model = new EscolaDeVoce.Services.ViewModel.CommentEscoleteTalkViewModel();

            model.Id      = Guid.Parse(id);
            model.comment = comment;
            model.userId  = Guid.Parse(getClaimValue("Id"));

            Infrastructure.ApiResponse <bool> commentresponse = null;
            System.Net.Http.HttpMethod        method          = System.Net.Http.HttpMethod.Post;
            commentresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.EscoleTalk.comment,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (commentresponse != null)
            {
                return(Json(new {
                    success = true
                }));
            }

            return(Json(new {
                success = false
            }));
            // return View();
        }
        public async Task <IActionResult> AnswerQuestion(string answerId, int score)
        {
            var model = new EscolaDeVoce.Services.ViewModel.UserAnswerQuestionViewModel();

            model.userId    = Guid.Parse(getClaimValue("Id"));
            model.answearId = Guid.Parse(answerId);
            model.score     = score;

            Infrastructure.ApiResponse <bool> mensagemresponse = null;
            System.Net.Http.HttpMethod        method           = System.Net.Http.HttpMethod.Post;
            mensagemresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.User.answerQuestion,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (mensagemresponse != null)
            {
                return(Json(new {
                    success = true
                }));
            }

            return(Json(new {
                success = false
            }));
        }
Exemple #5
0
        public async Task <IActionResult> sendMessage(string message, string to)
        {
            var model = new EscolaDeVoce.Services.ViewModel.MessageViewModel();

            model.fromId  = Guid.Parse(getClaimValue("Id"));
            model.message = message;
            model.toId    = Guid.Parse(to);
            model.title   = message;

            Infrastructure.ApiResponse <bool> mensagemresponse = null;
            System.Net.Http.HttpMethod        method           = System.Net.Http.HttpMethod.Post;
            mensagemresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Message.get,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (mensagemresponse != null)
            {
                return(Json(new {
                    success = true
                }));
            }

            return(Json(new {
                success = false
            }));
            // return View();
        }
Exemple #6
0
        public async Task <IActionResult> Signup(string username, string password, string email, string name, string lastname, string image, string cover, bool isFacebook)
        {
            var model = new EscolaDeVoce.Services.ViewModel.CreateUserViewModel();

            model.password = password;
            model.username = email;

            model.person          = new EscolaDeVoce.Services.ViewModel.PersonViewModel();
            model.person.name     = name;
            model.person.lastname = lastname;
            model.image           = image;
            model.cover           = cover;

            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.UserViewModel> createuserresponse = null;
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            createuserresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.UserViewModel> >(
                Helpers.EscolaDeVoceEndpoints.User.create,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (createuserresponse != null)
            {
                return(await this.Login(username, password, isFacebook));
            }

            return(Json(new {
                status = false
            }));
        }
        public async Task <IActionResult> startCourse(string courseId)
        {
            Infrastructure.ApiResponse <bool> courseResponse = null;
            System.Net.Http.HttpMethod        method         = System.Net.Http.HttpMethod.Post;
            courseResponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.User.startCourse + "/" + getClaimValue("Id") + "/" + courseId,
                method
                );

            return(Json(new { success = true }));
        }
        public async Task <IActionResult> Delete(Guid id)
        {
            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> response = null;
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Delete;

            response = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> >(
                Helpers.EscolaDeVoceEndpoints.Courses.getCourses + "/" + id.ToString(),
                method
                );

            return(RedirectToAction("Index"));
        }
Exemple #9
0
        public async Task <IActionResult> UpdateAccount([Bind("Id,name,lastname,cpf,haveBusiness,children,genre,birthday,phonenumber,email,addressTitle,addressStreet,addressPostalcode,addressCity,addressState,addressNumber,addressNeighborhood")] Services.ViewModel.PersonViewModel model)
        {
            Infrastructure.ApiResponse <bool> favoriteresponse = null;
            System.Net.Http.HttpMethod        method           = System.Net.Http.HttpMethod.Put;
            favoriteresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Person.get + "/" + model.Id,
                method,
                JsonConvert.SerializeObject(model)
                );

            return(Json(new {}));
        }
        public async Task <IActionResult> updateVideoStatus([Bind("progress,videoId")] Services.ViewModel.UpdateVideoStatusViewModel model)
        {
            Infrastructure.ApiResponse <bool> favoriteresponse = null;
            model.userId = Guid.Parse(getClaimValue("Id"));
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            favoriteresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Videos.updateStatus,
                method,
                JsonConvert.SerializeObject(model)
                );

            return(View());
        }
        public async Task <IActionResult> AddDictionaryItem([Bind("title,content,dictionaryType")] Services.ViewModel.DictionaryViewModel model)
        {
            Infrastructure.ApiResponse <bool> favoriteresponse = null;
            model.userId = Guid.Parse(getClaimValue("Id"));
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            favoriteresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.Dictionary.get,
                method,
                JsonConvert.SerializeObject(model)
                );

            return(View());
        }
        public async Task <IActionResult> Detail([Bind("Id,name,image,free,description,duration,schoolId,categoriesId,views,order")] Services.ViewModel.CourseViewModel model, ICollection <IFormFile> files)
        {
            var uploads = Path.Combine(_environment.WebRootPath, "images/specialists");

            if (files != null)
            {
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var fileextension = Path.GetExtension(file.FileName);
                        var filename      = Guid.NewGuid().ToString() + fileextension;
                        model.image = filename;

                        using (var fileStream = new FileStream(Path.Combine(uploads, filename), FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);
                        }
                    }
                }
            }

            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> response = null;

            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            string url = Helpers.EscolaDeVoceEndpoints.Courses.getCourses;

            if (model.Id != Guid.Empty)
            {
                method = System.Net.Http.HttpMethod.Put;
                url   += "/" + model.Id.ToString();
            }

            response = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.CourseViewModel> >(
                url,
                method,
                JsonConvert.SerializeObject(model)
                );

            if (model.Id != Guid.Empty || (response.data != null && response.data.Id != Guid.Empty))
            {
                var Id = model.Id != Guid.Empty ? model.Id : response.data.Id;
                return(RedirectToAction("Detail", new { id = Id.ToString() }));
            }
            return(RedirectToAction("Index"));
        }
        public async Task <IActionResult> Detail([Bind("Id,name")] Services.ViewModel.ProjectViewModel model)
        {
            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.ProjectViewModel> response = null;

            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            if (model.Id != Guid.Empty)
            {
                method = System.Net.Http.HttpMethod.Put;
            }

            response = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.ProjectViewModel> >(
                Helpers.EscolaDeVoceEndpoints.Project.getProjects + "/" + model.Id.ToString(),
                method,
                JsonConvert.SerializeObject(model)
                );

            return(View(response.data));
        }
Exemple #14
0
        public async Task <IActionResult> CoverPhotoUpload(string image)
        {
            var    webRoot   = _env.WebRootPath;
            var    imagename = Guid.NewGuid().ToString() + ".jpg";
            string filePath  = webRoot + "/images/" + imagename;
            var    baseImage = image.Replace("data:image/png;base64,", "");

            baseImage = baseImage.Replace("data:image/jpeg;base64,", "");
            baseImage = baseImage.Replace("data:image/jpg;base64,", "");
            baseImage = baseImage.Replace("\"", "");
            System.IO.File.WriteAllBytes(filePath, Convert.FromBase64String(baseImage));

            var userimage = new EscolaDeVoce.Services.ViewModel.UpdateUserCoverViewModel();

            userimage.Id    = Guid.Parse(getClaimValue("Id"));
            userimage.image = imagename;

            Infrastructure.ApiResponse <bool> updateimageresponse = null;
            System.Net.Http.HttpMethod        method = System.Net.Http.HttpMethod.Post;
            updateimageresponse = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <bool> >(
                Helpers.EscolaDeVoceEndpoints.User.changeCover,
                method,
                JsonConvert.SerializeObject(userimage)
                );

            if (updateimageresponse != null)
            {
                updateClaimValue("cover", imagename);
                return(Json(new {
                    success = true,
                    imageName = imagename,
                    imagepath = Request.Path
                }));
            }

            return(Json(new {
                success = false
            }));
        }
        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());
        }
Exemple #16
0
        public async Task <IActionResult> Detail([Bind("Id,name,charge,image,schoolId")] Services.ViewModel.EspecialistViewModel model, ICollection <IFormFile> files, [Bind("x,y,w,h")] Backend.ViewModel.SizeModel sizeModel)
        {
            var uploads = Path.Combine(_environment.WebRootPath, "images/specialists");

            if (files != null)
            {
                foreach (var file in files)
                {
                    if (file.Length > 0)
                    {
                        var fileextension = Path.GetExtension(file.FileName);
                        var filename      = Guid.NewGuid().ToString() + fileextension;
                        model.image = filename;

                        using (var fileStream = new FileStream(Path.Combine(uploads, filename), FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);
                        }

                        //Cortar imagem
                        Rectangle cropRect = new Rectangle(sizeModel.x, sizeModel.y, sizeModel.w, sizeModel.h);
                        Bitmap    src      = System.Drawing.Image.FromFile(Path.Combine(uploads, filename)) as Bitmap;
                        Bitmap    target   = new Bitmap(cropRect.Width, cropRect.Height);

                        using (Graphics g = Graphics.FromImage(target))
                        {
                            g.DrawImage(src,
                                        new Rectangle(0, 0, target.Width, target.Height),
                                        cropRect, GraphicsUnit.Pixel);
                        }

                        using (var fileStream = new FileStream(Path.Combine(uploads, "crp_" + filename), FileMode.Create))
                        {
                            await file.CopyToAsync(fileStream);
                        }
                    }
                }
            }

            Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.EspecialistViewModel> response = null;
            System.Net.Http.HttpMethod method = System.Net.Http.HttpMethod.Post;
            string url = Helpers.EscolaDeVoceEndpoints.Especialists.get;

            if (model.Id != Guid.Empty)
            {
                url   += "/" + model.Id.ToString();
                method = System.Net.Http.HttpMethod.Put;
            }

            response = await ApiRequestHelper.postPutRequest <Infrastructure.ApiResponse <EscolaDeVoce.Services.ViewModel.EspecialistViewModel> >(
                url,
                method,
                JsonConvert.SerializeObject(model)
                );

            if ((method == System.Net.Http.HttpMethod.Post && response.data != null && response.data.Id != Guid.Empty) || model.Id != Guid.Empty)
            {
                Guid Id = model.Id != Guid.Empty ? model.Id : response.data.Id;
                return(RedirectToAction("Detail", new { id = Id.ToString() }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }