Beispiel #1
0
        public ActionResult Novo()
        {
            var viewModel = new SheetClassFormViewModel()
            {
                Classe = new Models.SheetClass()
            };

            return(View("FormClasse", viewModel));
        }
Beispiel #2
0
        public ActionResult Editar(int id)
        {
            var classe = _dbContext.SheetClass.SingleOrDefault(c => c.Id == id);

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

            var viewModel = new SheetClassFormViewModel
            {
                Classe = classe
            };

            return(View("FormClasse", viewModel));
        }
Beispiel #3
0
        public ActionResult Salvar(Models.SheetClass classe)
        {
            ModelState.Remove("classe.Id");
            if (!ModelState.IsValid)
            {
                var viewModel = new SheetClassFormViewModel
                {
                    Classe = classe
                };

                return(View("FormClasse", viewModel));
            }

            if (classe.Id != 0)
            {
                _dbContext.Entry(classe).State = EntityState.Modified;
            }
            else
            {
                _dbContext.SheetClass.Add(classe);
            }
            _dbContext.SaveChanges();
            return(RedirectToAction("Index"));
        }