public BancaViewModel Update(BancaViewModel obj) { BeginTransaction(); _bancaService.Update(Mapper.Map <BancaViewModel, Banca>(obj)); Commit(); return(obj); }
public BancaViewModel Add(BancaViewModel obj) { var banca = Mapper.Map <BancaViewModel, Banca>(obj); BeginTransaction(); _bancaService.Add(banca); Commit(); return(obj); }
public ActionResult Edit(BancaViewModel bancaViewModel) { if (!ModelState.IsValid) { return(View(bancaViewModel)); } _bancaAppService.Update(bancaViewModel); return(RedirectToAction("Index")); }
// GET: Bancas/Details/5 // o id é o id do Tcc public async Task <IActionResult> Details(int?id) { if (id == null) { return(NotFound()); } Tcc tcc = _context.Tccs.Find(id); BancaViewModel bancaViewModel = new BancaViewModel(); bancaViewModel.Membros = new List <Banca>(); bancaViewModel.Membros.Add(_context.Banca .Include(b => b.Tcc) .Include(b => b.TipoUsuario) .Include(b => b.Usuario) .Where(b => b.TccId == tcc.TccId) .Where(b => b.TipoUsuario.DescTipo.ToLower().Equals("orientador")) .Select(b => new Banca { BancaId = b.BancaId, Tcc = b.Tcc, DataDeCadastro = b.DataDeCadastro, Nota = b.Nota, TipoUsuario = b.TipoUsuario, TccId = b.TccId, TipoUsuarioId = b.TipoUsuarioId, UsuarioId = b.UsuarioId, Usuario = new Usuario { Id = b.UsuarioId, Nome = b.Usuario.Nome } }) .First() ); bancaViewModel.Membros.AddRange(_context.Banca .Include(b => b.TipoUsuario) .Include(b => b.Usuario) .Where(b => b.TccId == tcc.TccId) .Where(b => !b.TipoUsuario.DescTipo.ToLower().Equals("orientador")) .Select(b => new Banca { Nota = b.Nota, TipoUsuario = b.TipoUsuario, UsuarioId = b.UsuarioId, BancaId = b.BancaId, Usuario = new Usuario { Id = b.UsuarioId, Nome = b.Usuario.Nome } }) .ToList()); if (bancaViewModel.Membros == null) { return(NotFound()); } bancaViewModel.BancaId = id.Value; return(View(bancaViewModel)); }
public ActionResult Create(BancaViewModel bancaViewModel) { _bancaAppService.Add(bancaViewModel); return(RedirectToAction("Index")); }