Ejemplo n.º 1
0
        public ActionResult Editar(Unitunes.Models.ViewModel.PodcastViewModel podcastViewModel)
        {
            var midiaRepo = Singleton <Unitunes.Models.Repositorios.Midia> .Instance();

            if (ModelState.IsValid)
            {
                if (podcastViewModel.arquivoUpload != null)
                {
                    if (podcastViewModel.arquivoUpload.ContentLength > 0)
                    {
                        var fileName = Path.GetFileName(podcastViewModel.arquivoUpload.FileName);
                        var path     = Path.Combine(Server.MapPath("~/App_Data/midias"), fileName);
                        //salva no servidor
                        podcastViewModel.arquivoUpload.SaveAs(path);


                        podcastViewModel.midia.Caminho = path;
                    }
                }

                //nao esquecer academicoID
                podcastViewModel.midia.Ativo       = true;
                podcastViewModel.midia.AcademicoId = Unitunes.Models.Servicos.Academico.getId();
                midiaRepo.Update(podcastViewModel.midia);

                return(Redirect("/Midia/Listar"));
            }
            return(View(podcastViewModel));
        }
Ejemplo n.º 2
0
        public ActionResult Deletar(Unitunes.Models.ViewModel.PodcastViewModel podcastViewModel)
        {
            var midiaRepo = Singleton <Unitunes.Models.Repositorios.Midia> .Instance();

            podcastViewModel.midia.Ativo = false;

            midiaRepo.Update(podcastViewModel.midia);
            return(Redirect("/Midia/Listar"));
        }