예제 #1
0
        public ActionResult DeleteConfirme(int id)
        {
            try
            {
                UserProfile userProfile = _db.UserProfiles.Find(id);

                // TODO: Add delete logic here
                if (Roles.GetRolesForUser(userProfile.UserName).Count() > 0)
                {
                    Roles.RemoveUserFromRoles(userProfile.UserName, Roles.GetRolesForUser(userProfile.UserName));
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, WebSecurity.GetUserId(userProfile.UserName));

                ((SimpleMembershipProvider)Membership.Provider).DeleteAccount(userProfile.UserName); // deletes record from webpages_Membership table

                userProfile.Excluido = true;

                _db.SaveChanges();


                //((SimpleMembershipProvider)Membership.Provider).DeleteUser(userProfile.UserName, false); // deletes record from UserProfile table


                return(RedirectToAction("index", "Usuarios"));
            }
            catch (Exception ex)
            {
                return(View(id));
            }
        }
예제 #2
0
        public ActionResult Login(LoginModel model, string returnUrl)
        {
            if (ModelState.IsValid && WebSecurity.Login(model.UserName, model.Password, persistCookie: model.RememberMe))
            {
                var user = _db.UserProfiles.Where(x => x.UserName == model.UserName).FirstOrDefault();

                if (user.Excluido)
                {
                    WebSecurity.Logout();

                    ModelState.AddModelError("", "Usuário Excluido! Contate um administrador.");
                    return(View(model));
                }

                if (!user.Ativo)
                {
                    WebSecurity.Logout();

                    ModelState.AddModelError("", "Usuário Inativo! Contate um administrador.");
                    return(View(model));
                }

                GerenciaLogs.saveLog(ref db, user.UserId, 39, TipoAcesso.Acesso);

                return(RedirectToLocal(returnUrl));
            }

            // If we got this far, something failed, redisplay form
            ModelState.AddModelError("", "Senha ou usuário inválido.");
            return(View(model));
        }
예제 #3
0
        public ActionResult Create(Apresentadores apresentadores, HttpPostedFileBase fotoExterna)
        {
            if (ModelState.IsValid)
            {
                if (fotoExterna != null)
                {
                    var pathinterna = Server.MapPath(caminhoInterna);
                    var pathLista   = Server.MapPath(caminhoListagem);

                    //  apresentadores.fotoInterna = Utils.SaveAndCropImage(fotoInterna, pathinterna, 0, 0, 621, 201);

                    apresentadores.fotoExterna = Utils.SaveAndCropImage(fotoExterna, pathLista, 0, 0, 110, 110);
                }
                ;

                int suffix = 0;

                do
                {
                    apresentadores.chave = apresentadores.nome.GenerateSlug() + (suffix > 0 ? (suffix++).ToString() : "");
                    suffix++;
                } while (db.Apresentadores.Where(o => o.chave == apresentadores.chave).Count() > 0);

                apresentadores.DataCadastro = DateTime.Now;
                db.Apresentadores.Add(apresentadores);
                db.SaveChanges();

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areadADM, TipoAcesso.Insercao, apresentadores.id);

                return(RedirectToAction("Index"));
            }

            return(View(apresentadores));
        }
예제 #4
0
        public ActionResult Create(Bastidores galeria)
        {
            if (ModelState.IsValid)
            {
                galeria.excluido     = false;
                galeria.dataCadastro = DateTime.Now;

                int suffix = 0;

                do
                {
                    galeria.chave = galeria.titulo.GenerateSlug() + (suffix > 0 ? (suffix++).ToString() : "");
                    suffix++;
                } while (db.Materia.Where(o => o.chave == galeria.chave).Count() > 0);

                db.Bastidores.Add(galeria);
                db.SaveChanges();

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, galeria.id);

                return(RedirectToAction("Edit", new { id = galeria.id }));
            }

            return(View(galeria));
        }
예제 #5
0
        public ActionResult Responder(FaleConosco faleconosco)
        {
            if (ModelState.IsValid)
            {
                faleconosco.lida            = 1;
                db.Entry(faleconosco).State = EntityState.Modified;

                faleconosco.dataResposta = DateTime.Now;
                faleconosco.assunto      = "";

                String body = System.IO.File.ReadAllText(Server.MapPath("~/ModelosEmail/modeloemail.asp"));

                var emailModel = new MailModel();

                body = body.Replace("##nome##", faleconosco.nome);
                body = body.Replace("##mensagem##", faleconosco.mensagem);
                body = body.Replace("##resposta##", faleconosco.resposta);
                body = body.Replace("../", "http://" + Request.Url.Authority + "/");

                body = body.Replace("##data##", DateTime.Now.ToString("dd/MM/yyyy"));

                emailModel.Body    = body;
                emailModel.Subject = "Rádio CompanyName - Fale Conosco";
                emailModel.To      = faleconosco.email;

                emailModel.SendEmail();

                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, faleconosco.id);
                return(RedirectToAction("Index"));
            }
            return(View(faleconosco));
        }
예제 #6
0
        public ActionResult Edit(Equipe equipe, HttpPostedFileBase Arquivo)
        {
            if (ModelState.IsValid)
            {
                db.Entry(equipe).State = EntityState.Modified;
                db.SaveChanges();

                if (Arquivo != null)
                {
                    string caminho = Server.MapPath("~/conteudo/equipe/165x165/");
                    equipe.imagem = Utils.SaveAndCropImage(Arquivo, caminho, 0, 0, 165, 165);
                }

                int suffix = 0;

                do
                {
                    equipe.chave = equipe.nome.GenerateSlug() + (suffix > 0 ? (suffix++).ToString() : "");
                    suffix++;
                } while (db.Materia.Where(o => o.chave == equipe.chave).Count() > 0);

                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, equipe.id);
                return(RedirectToAction("Index"));
            }
            return(View(equipe));
        }
예제 #7
0
        public ActionResult Edit(Acontecimentos acontecimento)
        {
            if (!string.IsNullOrWhiteSpace(acontecimento.FlickrId))
            {
                var flickr = new CompanyNameFlickr();

                var imagens = flickr.PhotosetsGetPhotos(acontecimento.FlickrId, 1, 1);

                if (imagens == null)
                {
                    ModelState.AddModelError("FlickrId", "Não foi encontrado um álbum com esse flickrId.");
                }
            }

            if (ModelState.IsValid)
            {
                db.Entry(acontecimento).State = EntityState.Modified;
                db.Entry(acontecimento).Property("DataCadastro").IsModified = false;
                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, acontecimento.Id);
                return(RedirectToAction("Index", "Acontecimentos", new { evento = acontecimento.EventoId }));
            }
            ViewBag.EventoId = new SelectList(db.Eventos, "Id", "Titulo", acontecimento.EventoId);
            return(View(acontecimento));
        }
예제 #8
0
        public ActionResult Edit(TimesPADs time, HttpPostedFileBase fotoUpload)
        {
            Validacao(time);
            if (ModelState.IsValid)
            {
                time.DataCadastro = DateTime.Now;
                time.Excluido     = false;

                #region uploads

                if (fotoUpload != null)
                {
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, time.Id));
                    var path100x100  = Server.MapPath(string.Format(pathLogo100x100, time.Id));

                    time.Logo = Utils.SaveFileBase(fileOriginal, fotoUpload);
                    Utils.resizeImageAndSave3(Path.Combine(fileOriginal, time.Logo), 100, 100, path100x100);
                }

                db.Entry(time).State = EntityState.Modified;
                db.SaveChanges();
                #endregion

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, time.Id);
                return(RedirectToAction("Details", new { id = time.Id }));
            }
            return(View(time));
        }
예제 #9
0
        public ActionResult Cadastrar(RegisterModel user, string[] roles)
        {
            if (ModelState.IsValid)
            {
                WebSecurity.CreateUserAndAccount(user.UserName, user.Password, new { Nome = user.Nome, Email = user.Email, Ativo = user.Ativo });

                if (roles != null)
                {
                    if (roles.Contains("Administrador"))
                    {
                        Roles.AddUserToRole(user.UserName, "Administrador");
                    }
                    else
                    {
                        Roles.AddUserToRoles(user.UserName, roles);
                    }
                }
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, WebSecurity.GetUserId(user.UserName));

                return(RedirectToAction("Index"));
            }

            ViewBag.Roles = Roles.GetAllRoles().Where(r => r != "Administrador").ToList();
            return(View(user));
        }
예제 #10
0
        public ActionResult DeleteConfirmed(int id)
        {
            Colunista colunista = db.Colunista.Find(id);

            try
            {
                UserProfile userProfile = _db.UserProfiles.Where(x => x.ColunistaId == colunista.id).FirstOrDefault();

                if (userProfile != null)
                {
                    if (Roles.GetRolesForUser(userProfile.UserName).Count() > 0)
                    {
                        Roles.RemoveUserFromRoles(userProfile.UserName, Roles.GetRolesForUser(userProfile.UserName));
                    }

                    ((SimpleMembershipProvider)Membership.Provider).DeleteAccount(userProfile.UserName);    // deletes record from webpages_Membership table
                    ((SimpleMembershipProvider)Membership.Provider).DeleteUser(userProfile.UserName, true); // deletes record from UserProfile table
                }
            }
            catch
            {
                return(View(colunista));
            }

            colunista.excluido        = true;
            db.Entry(colunista).State = EntityState.Modified;
            db.SaveChanges();

            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Exclusao, colunista.id);
            return(RedirectToAction("Index", "Colunistas"));
        }
예제 #11
0
        public ActionResult Edit(RedesSociaisPADs noticia, HttpPostedFileBase fotoUpload, int cropX = 0, int cropY = 0, int cropWidth = 0, int cropHeight = 0)
        {
            Validacao(noticia);
            if (ModelState.IsValid)
            {
                noticia.DataCadastro = DateTime.Now;
                noticia.Excluido     = false;

                if (fotoUpload != null)
                {
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, noticia.Id));

                    if (cropWidth > 0 && cropHeight > 0)
                    {
                        noticia.Foto = "/Admin/Conteudo/RedesSociaisPAD/" + noticia.Id + "/" + Utils.SaveAndCropColunista(fotoUpload, fileOriginal, cropX, cropY, cropWidth, cropHeight);
                    }
                    else
                    {
                        noticia.Foto = "/Admin/Conteudo/RedesSociaisPAD/" + noticia.Id + "/" + Utils.SaveFileBase(fileOriginal, fotoUpload);
                    }
                }

                db.Entry(noticia).State = EntityState.Modified;
                db.SaveChanges();

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, noticia.Id);
                return(RedirectToAction("Details", new { id = noticia.Id }));
            }

            ApoioViewBag(noticia);

            return(View(noticia));
        }
예제 #12
0
        public ActionResult Edit(ApoioPADs apoio, HttpPostedFileBase fotoUpload)
        {
            Validacao(apoio);
            if (ModelState.IsValid)
            {
                apoio.DataCadastro = DateTime.Now;
                apoio.Excluido     = false;

                #region uploads

                if (fotoUpload != null)
                {
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, apoio.Id));

                    apoio.Logo = Utils.SaveFileBase(fileOriginal, fotoUpload);
                }

                db.Entry(apoio).State = EntityState.Modified;
                db.SaveChanges();
                #endregion

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, apoio.Id);
                return(RedirectToAction("Details", new { id = apoio.Id }));
            }
            return(View(apoio));
        }
예제 #13
0
        public ActionResult Create(ApoioPADs apoio, HttpPostedFileBase logo)
        {
            Validacao(apoio);
            if (logo == null)
            {
                ModelState.AddModelError("Logo", "O Apoiador deve ter um logo.");
            }
            if (ModelState.IsValid)
            {
                apoio.Excluido     = false;
                apoio.DataCadastro = DateTime.Now;

                db.ApoioPADs.Add(apoio);

                if (db.SaveChanges() > 0)
                {
                    #region uploads
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, apoio.Id));
                    apoio.Logo = Utils.SaveFileBase(fileOriginal, logo);

                    db.Entry(apoio).State = EntityState.Modified;
                    db.SaveChanges();
                    #endregion
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, apoio.Id);
                return(RedirectToAction("Index"));
            }
            return(View(apoio));
        }
예제 #14
0
        public ActionResult Create(TimesPADs time, HttpPostedFileBase logo)
        {
            Validacao(time);
            if (logo == null)
            {
                ModelState.AddModelError("Logo", "O time deve ter um logo.");
            }
            if (ModelState.IsValid)
            {
                time.Excluido     = false;
                time.DataCadastro = DateTime.Now;

                db.TimesPADs.Add(time);

                if (db.SaveChanges() > 0)
                {
                    #region uploads
                    var fileOriginal = Server.MapPath(string.Format(pathOriginal, time.Id));
                    var path100x100  = Server.MapPath(string.Format(pathLogo100x100, time.Id));

                    time.Logo = Utils.SaveFileBase(fileOriginal, logo);
                    Utils.resizeImageAndSave3(Path.Combine(fileOriginal, time.Logo), 100, 100, path100x100);

                    db.Entry(time).State = EntityState.Modified;
                    db.SaveChanges();
                    #endregion
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, time.Id);
                return(RedirectToAction("Index"));
            }
            return(View(time));
        }
예제 #15
0
        public ActionResult Editar(UserProfile user, string[] roles)
        {
            if (ModelState.IsValid)
            {
                _db.Entry(user).State = EntityState.Modified;
                _db.SaveChanges();
                if (Roles.GetRolesForUser(user.UserName).Length > 0)
                {
                    Roles.RemoveUserFromRoles(user.UserName, Roles.GetRolesForUser(user.UserName));
                }

                if (roles != null)
                {
                    if (roles.Contains("Administrador"))
                    {
                        Roles.AddUserToRole(user.UserName, "Administrador");
                    }
                    else
                    {
                        Roles.AddUserToRoles(user.UserName, roles);
                    }
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, WebSecurity.GetUserId(user.UserName));

                return(RedirectToAction("Index"));
            }

            ViewBag.Roles    = Roles.GetRolesForUser(user.UserName);
            ViewBag.AllRoles = Roles.GetAllRoles().Where(r => r != "Administrador");
            return(View());
        }
예제 #16
0
        public ActionResult Create(Acontecimentos acontecimento, int evento)
        {
            if (!string.IsNullOrWhiteSpace(acontecimento.FlickrId))
            {
                var flickr = new CompanyNameFlickr();

                var imagens = flickr.PhotosetsGetPhotos(acontecimento.FlickrId, 1, 1);

                if (imagens == null)
                {
                    ModelState.AddModelError("FlickrId", "Não foi encontrado um álbum com esse flickrId.");
                }
            }

            if (ModelState.IsValid)
            {
                acontecimento.DataCadastro = DateTime.Now;
                db.Acontecimentos.Add(acontecimento);
                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, acontecimento.Id);
                return(RedirectToAction("Index", "Acontecimentos", new { evento = evento }));
            }

            ViewBag.EventoId = new SelectList(db.Eventos.Where(evt => !evt.Excluido), "Id", "Titulo", evento);
            ViewBag.Evento   = db.Eventos.FirstOrDefault(a => a.Id == evento && !a.Excluido);

            return(View(acontecimento));
        }
예제 #17
0
        public ActionResult Edit(Apresentadores apresentadores, HttpPostedFileBase fotoExternaUpload)
        {
            if (ModelState.IsValid)
            {
                if (fotoExternaUpload != null)
                {
                    var pathLista = Server.MapPath(caminhoListagem);
                    apresentadores.fotoExterna = Utils.SaveAndCropImage(fotoExternaUpload, pathLista, 0, 0, 110, 110);
                }
                ;



                int suffix = 0;

                do
                {
                    apresentadores.chave = apresentadores.nome.GenerateSlug() + (suffix > 0 ? (suffix++).ToString() : "");
                    suffix++;
                } while (db.Apresentadores.Where(o => o.chave == apresentadores.chave && o.id != apresentadores.id).Count() > 0);


                db.Entry(apresentadores).State = EntityState.Modified;
                db.Entry(apresentadores).Property("DataCadastro").IsModified = false;
                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areadADM, TipoAcesso.Edicao, apresentadores.id);
                return(RedirectToAction("Index"));
            }

            return(View(apresentadores));
        }
예제 #18
0
        //
        // POST: /Account/LogOff


        public ActionResult LogOff()
        {
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), 40, TipoAcesso.Saida);

            WebSecurity.Logout();

            return(RedirectToAction("Index", "Home"));
        }
예제 #19
0
        public ActionResult Edit(GruposPush grupo, string ListaTags = "")
        {
            if (ModelState.IsValid)
            {
                #region Tags
                db.Entry(grupo).State = EntityState.Modified;

                db.Entry(grupo).Collection("Tags").Load();
                grupo.Tags.Clear();

                if (!string.IsNullOrEmpty(ListaTags))
                {
                    grupo.Tags = new List <Tags>();
                    string[] tagList = ListaTags.Split(new char[] { ',' });

                    foreach (var item in tagList)
                    {
                        var hasTag = db.Tags.FirstOrDefault(x => x.Titulo.ToLower() == item.ToLower());

                        if (hasTag != null)
                        {
                            grupo.Tags.Add(hasTag);
                        }
                        else
                        {
                            var obj = new Tags
                            {
                                chave        = item.GenerateSlug(),
                                DataCadastro = DateTime.Now,
                                Excluido     = false,
                                Titulo       = item
                            };

                            db.Tags.Add(obj);
                            db.SaveChanges();

                            grupo.Tags.Add(obj);
                        }
                    }
                }
                #endregion

                grupo.DataCadastro = DateTime.Now;
                grupo.Excluido     = false;

                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Edicao, grupo.Id);
                return(RedirectToAction("Index"));
            }

            ViewBag.MultiSelectTags  = new MultiSelectList(db.Tags.Where(a => !a.Excluido), "Id", "Titulo");
            ViewBag.AutoCompleteTags = db.Tags.Where(a => !a.Excluido).Select(x => x.Titulo).ToArray();

            var tags = grupo.Tags.Select(x => x.Titulo).ToArray();
            ViewBag.tagsNoticia = string.Join(",", tags);

            return(View(grupo));
        }
예제 #20
0
        public ActionResult Create(Enquete enquete, string[] resposta, string[] correta)
        {
            if (ModelState.IsValid)
            {
                db.Enquete.Add(enquete);
                enquete.dataCadastro = DateTime.Now;

                int suffix = 0;

                do
                {
                    enquete.chave = enquete.pergunta.GenerateSlug() + (suffix > 0 ? suffix.ToString() : "");
                    suffix++;
                } while (db.Enquete.Where(o => o.chave == enquete.chave).Count() > 0);

                try
                {
                    db.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    #region just-debug
                    foreach (var eve in e.EntityValidationErrors)
                    {
                        Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:",
                                          eve.Entry.Entity.GetType().Name, eve.Entry.State);
                        foreach (var ve in eve.ValidationErrors)
                        {
                            Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
                                              ve.PropertyName, ve.ErrorMessage);
                        }
                        //throw;
                    }
                    #endregion
                }

                for (int cont = 0; cont < resposta.Count(); cont++)
                {
                    if (resposta[cont] != null && resposta[cont] != "")
                    {
                        Respostas respostas = new Respostas();

                        respostas.idEnquete = enquete.id;
                        respostas.resposta  = resposta[cont];
                        respostas.votos     = 0;

                        respostas.excluido = false;

                        db.Respostas.Add(respostas);
                        db.SaveChanges();
                    }
                }
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, enquete.id);
                return(RedirectToAction("Index"));
            }

            return(View(enquete));
        }
예제 #21
0
        public ActionResult Create(Secoes_Locais local, HttpPostedFileBase Imagem, string fotoExistente = "")
        {
            if (ModelState.IsValid)
            {
                local.DataCadastro = DateTime.Now;
                local.Excluido     = false;

                db.Secoes_Locais.Add(local);


                var editoriaId = db.Editoriais.FirstOrDefault(x => x.Especiais_Secoes.Any(w => w.Id == local.SecaoId)).id;

                if (db.SaveChanges() > 0)
                {
                    if (Imagem != null)
                    {
                        var path405x270 = Server.MapPath(string.Format(pathFoto405x270, local.Id));
                        var path365x240 = Server.MapPath(string.Format(pathFoto365x240, local.Id));
                        var path260x173 = Server.MapPath(string.Format(pathFoto260x173, local.Id));

                        var fileOriginal = Server.MapPath(string.Format(pathOriginal, local.Id));

                        local.Imagem = Utils.SaveFileBase(fileOriginal, Imagem);


                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, local.Imagem), 405, 270, path405x270);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, local.Imagem), 365, 240, path365x240);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, local.Imagem), 260, 173, path260x173);
                    }

                    int suffix = 0;

                    do
                    {
                        local.Chave = local.Titulo.GenerateSlug() + (suffix > 0 ? suffix.ToString() : "");
                        suffix++;
                    } while (db.Secoes_Locais.Where(o => o.Chave == local.Chave).Count() > 0);


                    if (!string.IsNullOrEmpty(fotoExistente))
                    {
                        local.Imagem = fotoExistente;
                    }

                    db.Entry(local).State = EntityState.Modified;
                    db.SaveChanges();
                }


                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, local.Id);
                return(RedirectToAction("Index", new { EspecialId = editoriaId }));
            }
            var especialId = db.Editoriais.FirstOrDefault(x => x.Especiais_Secoes.Any(w => w.Id == local.SecaoId)).id;

            ViewBag.SecaoId = new SelectList(db.Especiais_Secoes.Where(x => x.EditoriaId == especialId && !x.Excluido), "Id", "Titulo", local.SecaoId);
            return(View(local));
        }
예제 #22
0
        public ActionResult Create(Colunista colunista, HttpPostedFileBase foto, HttpPostedFileBase fotoMini, string username = "", string password = "", int cropX = 0, int cropY = 0, int cropWidth = 190, int cropHeight = 132)
        {
            if (ModelState.IsValid)
            {
                string criarUsuario = Request.Form["CriarUsuario"];

                if (criarUsuario == "Sim")
                {
                    username = colunista.nome.GenerateSlug();
                    password = "******";
                }

                if (foto != null)
                {
                    if (cropWidth > 0)
                    {
                        colunista.foto = Utils.SaveAndCropColunista(foto, Server.MapPath("~/Conteudo/Colunistas/Foto/"), cropX, cropY, cropWidth, cropHeight);
                    }
                    else
                    {
                        colunista.foto = Utils.SaveAndCropImage(foto, Server.MapPath("~/Conteudo/Colunistas/Foto/"), 0, 0, 190, 132);
                    }
                }
                colunista.dataCadastro = DateTime.Now;

                int suffix = 0;

                do
                {
                    colunista.chave = colunista.nome.GenerateSlug() + (suffix > 0 ? (suffix++).ToString() : "");
                    suffix++;
                } while (db.Colunista.Where(o => o.chave == colunista.chave).Count() > 0);

                db.Colunista.Add(colunista);
                db.SaveChanges();

                try
                {
                    if (criarUsuario == "Sim")
                    {
                        WebSecurity.CreateUserAndAccount(username, password, propertyValues: new { ColunistaId = colunista.id, Email = colunista.email, Ativo = colunista.liberado, Nome = colunista.nome }, requireConfirmationToken: false);
                        Roles.AddUserToRole(username, "Colunistas");
                    }
                }
                catch (MembershipCreateUserException e)
                {
                    ModelState.AddModelError("Cadastro", ErrorCodeToString(e.StatusCode));
                    //return View(colunista);
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, colunista.id);

                return(RedirectToAction("Index"));
            }

            return(View(colunista));
        }
예제 #23
0
        public ActionResult DeleteConfirmed(int id)
        {
            Apresentadores apresentadores = db.Apresentadores.Find(id);

            db.Apresentadores.Remove(apresentadores);
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areadADM, TipoAcesso.Exclusao, apresentadores.id);
            return(RedirectToAction("Index"));
        }
예제 #24
0
        public ActionResult Create(MidiaKit midiakit, HttpPostedFileBase Arquivo, HttpPostedFileBase Miniatura)
        {
            if (ModelState.IsValid)
            {
                midiakit.Excluido     = false;
                midiakit.DataCadastro = DateTime.Now;

                db.MidiaKit.Add(midiakit);
                db.SaveChanges();

                if (Arquivo != null)
                {
                    string caminho = Server.MapPath("~/conteudo/MidiaKit/");

                    var extension = Path.GetExtension(Arquivo.FileName);

                    string[] permitidos = { ".jpg", ".jpeg", ".gif", ".js", ".zip", ".png", ".rar", ".doc", ".docx", ".txt", ".mp3 ", ".pdf", ".mpeg", ".mp4", ".ogg" };

                    if (!permitidos.Contains(extension.ToLower()))
                    {
                        ModelState.AddModelError("", "Extensão não permitida!");
                    }
                    else
                    {
                        Arquivo.SaveAs(caminho + Arquivo.FileName);
                        midiakit.Arquivo = Arquivo.FileName;
                    }
                }


                if (Miniatura != null)
                {
                    var extension = Path.GetExtension(Arquivo.FileName);

                    string[] permitidos = { ".jpg", ".jpeg", ".gif", ".png" };

                    if (!permitidos.Contains(extension.ToLower()))
                    {
                        ModelState.AddModelError("", "Extensão não permitida!");
                    }
                    else
                    {
                        var pathArquivoFinal = Server.MapPath("~/conteudo/MidiaKit/miniaturas/");

                        Miniatura.SaveAs(Path.Combine(pathArquivoFinal, Miniatura.FileName));
                        midiakit.Miniatura = Miniatura.FileName;
                    }
                }

                db.SaveChanges();
                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, midiakit.Id);
                return(RedirectToAction("Index"));
            }

            return(View(midiakit));
        }
예제 #25
0
        public ActionResult Create(Blocos blocos, HttpPostedFileBase Imagem, string fotoExistente = "")
        {
            if (!string.IsNullOrEmpty(fotoExistente))
            {
                blocos.Imagem = fotoExistente;
                ModelState.Remove("Imagem");
            }

            if (ModelState.IsValid)
            {
                blocos.Excluido     = false;
                blocos.DataCadastro = DateTime.Now;

                db.Blocos.Add(blocos);

                if (db.SaveChanges() > 0)
                {
                    #region image e slug
                    if (Imagem != null)
                    {
                        //   var path1400x629 = Server.MapPath(string.Format(pathFoto1400x629, blocos.Id));
                        var path744x500 = Server.MapPath(string.Format(pathFoto744x500, blocos.Id));
                        var path405x270 = Server.MapPath(string.Format(pathFoto405x270, blocos.Id));
                        var path365x240 = Server.MapPath(string.Format(pathFoto365x240, blocos.Id));
                        var path260x173 = Server.MapPath(string.Format(pathFoto260x173, blocos.Id));

                        var fileOriginal = Server.MapPath(string.Format(pathOriginal, blocos.Id));

                        blocos.Imagem = Utils.SaveFileBase(fileOriginal, Imagem);

                        //Utils.resizeImageAndSave3(Path.Combine(fileOriginal, blocos.Imagem), 1400, 629, path1400x629);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, blocos.Imagem), 744, 500, path744x500);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, blocos.Imagem), 405, 270, path405x270);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, blocos.Imagem), 365, 240, path365x240);
                        Utils.resizeImageAndSave3(Path.Combine(fileOriginal, blocos.Imagem), 260, 173, path260x173);
                    }

                    int suffix = 0;

                    do
                    {
                        blocos.Chave = blocos.Nome.GenerateSlug() + (suffix > 0 ? suffix.ToString() : "");
                        suffix++;
                    } while (db.Blocos.Where(o => o.Chave == blocos.Chave).Count() > 0);
                    #endregion

                    db.Entry(blocos).State = EntityState.Modified;
                    db.SaveChanges();
                }

                GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Insercao, blocos.Id);
                return(RedirectToAction("Index"));
            }

            return(View(blocos));
        }
예제 #26
0
        public ActionResult DeleteConfirmed(int id)
        {
            Noticias noticias = db.Noticias.Find(id);

            noticias.excluido        = true;
            db.Entry(noticias).State = EntityState.Modified;
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), getAreaADM(noticias.Editoriais.FirstOrDefault().id), TipoAcesso.Edicao, noticias.id);
            return(RedirectToAction("Index", new { EspecialId = noticias.Editoriais.FirstOrDefault().id }));
        }
예제 #27
0
        public ActionResult DeleteConfirmed(int id)
        {
            Noticias noticias = db.Noticias.Find(id);

            noticias.excluido        = true;
            db.Entry(noticias).State = EntityState.Modified;
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Exclusao, noticias.id);
            return(RedirectToAction("Index"));
        }
예제 #28
0
        public ActionResult VideosDeleteConfirmed(int id)
        {
            BastidoresMidias video = db.BastidoresMidias.Find(id);

            video.excluido        = true;
            db.Entry(video).State = EntityState.Modified;
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM2, TipoAcesso.Exclusao, video.id);
            return(RedirectToAction("Videos"));
        }
예제 #29
0
        public ActionResult DeleteConfirmedResposta(int id)
        {
            Respostas resposta  = db.Respostas.Find(id);
            var       idEnquete = resposta.idEnquete;

            db.Respostas.Remove(resposta);
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM2, TipoAcesso.Exclusao, resposta.id);
            return(RedirectToAction("Edit/" + idEnquete));
        }
예제 #30
0
        public ActionResult DeleteConfirmed(int id)
        {
            Especiais_Secoes especiais_secoes = db.Especiais_Secoes.Find(id);

            especiais_secoes.Excluido        = true;
            db.Entry(especiais_secoes).State = EntityState.Modified;
            //db.Especiais_Secoes.Remove(especiais_secoes);
            db.SaveChanges();
            GerenciaLogs.saveLog(ref db, WebSecurity.GetUserId(User.Identity.Name), areaADM, TipoAcesso.Exclusao, especiais_secoes.Id);
            return(RedirectToAction("Index", new { EditorialId = especiais_secoes.EditoriaId }));
        }