Esempio n. 1
0
        public ActionResult CadastroTema()
        {
            var pj        = (Fornecedor)Session["usuarioFornecedorLogado"];
            var modelTema = new TemaViewModel()
            {
                FornecedorId = pj.Id
            };

            return(View("CadastroTema", modelTema));
        }
 public int Add(TemaViewModel entity)
 {
     m_TemaService.Add(new Data.EV_TEMA
     {
         TEMA          = entity.Tema,
         DTATUALIZACAO = DateTime.Now,
         DTCADASTRO    = DateTime.Now,
     });
     return(m_TemaService.Commit());
 }
        public int Delete(TemaViewModel entity)
        {
            var item = m_TemaService.GetById(entity.Id);

            if (item != null)
            {
                item.DTEXCLUSAO = DateTime.Now;
                m_TemaService.Update(item);
            }
            return(m_TemaService.Commit());
        }
        public int Update(TemaViewModel entity)
        {
            var item = m_TemaService.GetById(entity.Id);

            if (item != null)
            {
                item.TEMA          = entity.Tema;
                item.DTATUALIZACAO = DateTime.Now;
                m_TemaService.Update(item);
            }

            return(m_TemaService.Commit());
        }
Esempio n. 5
0
        public ActionResult Create(TemaViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var temaCrear = new Tema(viewModel, db);
                new Repositorio <Tema>(db).Crear(temaCrear);

                return(RedirectToAction("Index"));
            }

            viewModel.RegenerarVista(db);

            return(View(viewModel));
        }
Esempio n. 6
0
        public ActionResult Edit(TemaViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                Tema tema = new Repositorio <Tema>(db).Traer(viewModel.Id);

                tema.Modificar(viewModel, db);
                new Repositorio <Tema>(db).Modificar(tema);

                return(RedirectToAction("Index"));
            }

            viewModel.RegenerarVista(db);

            return(View(viewModel));
        }
Esempio n. 7
0
        public ActionResult CadastroTema(TemaViewModel temaViewModel)
        {
            var imageTypes = new string[] {
                "image/gif",
                "image/jpeg",
                "image/pjpeg",
                "image/png"
            };

            if (temaViewModel.ImageUpload == null || temaViewModel.ImageUpload.ContentLength == 0)
            {
                ModelState.AddModelError("ImageUpload.vazio", "Este campo é obrigatório!");
            }
            else if (!imageTypes.Contains(temaViewModel.ImageUpload.ContentType))
            {
                ModelState.AddModelError("ImageUpload.sem", "Escolha uma imagem GIF, JPG ou PNG.");
            }

            if (ModelState.IsValid)
            {
                var tema = new Tema();
                tema.Nome               = temaViewModel.Nome;
                tema.Descricao          = temaViewModel.Descricao;
                tema.LinkSolicitarFesta = temaViewModel.LinkPedirFesta;
                tema.LinkAlbum          = temaViewModel.LinkAlbumFacebook;
                tema.FornecedorId       = temaViewModel.FornecedorId;

                var imagemNome = String.Format("{0:yyyyMMdd-HHmmssfff}", DateTime.Now);
                var extensao   = System.IO.Path.GetExtension(temaViewModel.ImageUpload.FileName).ToLower();

                using (var img = System.Drawing.Image.FromStream(temaViewModel.ImageUpload.InputStream))
                {
                    tema.Imagem = String.Format("/Imagens/{0}{1}", imagemNome, extensao);
                    // Salva imagem
                    SalvarNaPasta(img, tema.Imagem);
                }

                temaDAO.Adicionar(tema);
                return(RedirectToAction("ListarTemasParaFornecedor", "Tema"));
            }
            else
            {
                return(View(temaViewModel));
            }
        }
Esempio n. 8
0
        public ActionResult Edit(Guid?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Tema temaModificar = new Repositorio <Tema>(db).Traer(id.Value);

            if (temaModificar == null)
            {
                return(HttpNotFound());
            }

            var temaViewModel = new TemaViewModel(temaModificar, db);

            return(View(temaViewModel));
        }
Esempio n. 9
0
 internal void Modificar(TemaViewModel viewModel, ApplicationDbContext db)
 {
     Nombre      = viewModel.Nombre;
     SpotifyLink = viewModel.SpotifyLink;
     Artista     = new Repositorio <ArtistaBase>(db).Traer(viewModel.ArtistaId);
 }
Esempio n. 10
0
 public Tema(TemaViewModel viewModel, ApplicationDbContext db)
 {
     Modificar(viewModel, db);
 }
 public SeleccionaTema()
 {
     InitializeComponent();
     BindingContext = new TemaViewModel();
 }