public async Task <SetorProprietario> GetById(int?id) { SetorProprietario setorProprietario = await _context.SetorProprietarios .Include(p => p.Empresa) .AsNoTracking() .SingleOrDefaultAsync(p => p.Id == id); return(setorProprietario); }
public async Task <IActionResult> EditSetor(SetorProprietario setorProprietario) { if (ModelState.IsValid) { await setorProprietarioDAO.Edit(setorProprietario); return(RedirectToAction("Index")); } await PopulateEmpresaDropDownList(setorProprietario.EmpresaId); return(View(setorProprietario)); }
public async Task <IActionResult> DeleteSetor(int?id) { if (id.HasValue) { SetorProprietario setorProprietario = await setorProprietarioDAO.GetById(id); await setorProprietarioDAO.Remove(setorProprietario); return(RedirectToAction("Index")); } HttpContext.Response.StatusCode = 400; return(RedirectToAction("Index")); }
public async Task <IActionResult> EditSetor(int?id) { if (id.HasValue) { SetorProprietario setorProprietario = await setorProprietarioDAO.GetById(id); if (setorProprietario != null) { await PopulateEmpresaDropDownList(setorProprietario.EmpresaId); return(View(setorProprietario)); } } return(RedirectToAction("Index")); }
public async Task Edit(SetorProprietario setorProprietario) { _context.Update(setorProprietario); await _context.SaveChangesAsync(); }
public async Task Remove(SetorProprietario setorProprietario) { _context.Remove(setorProprietario); await _context.SaveChangesAsync(); }
public async Task Create(SetorProprietario setorProprietario) { _context.Add(setorProprietario); await _context.SaveChangesAsync(); }