public async Task <IActionResult> PutMainDep(int id, MainDep mainDep) { if (id != mainDep.MainDepID) { return(BadRequest()); } _context.Entry(mainDep).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!MainDepExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
//[Authorize] public async Task <ActionResult <MainDep> > PostMainDep(MainDep mainDep) { //mainDep.DepartmentList = new List<Department>(); _context.MainDeps.Add(mainDep); await _context.SaveChangesAsync(); return(CreatedAtAction("GetMainDep", new { id = mainDep.MainDepID }, mainDep)); }
public async Task <ActionResult <MainDep> > PostMainDep(MainDep model) { dbContext.MainDeps.Add(model); try { await dbContext.SaveChangesAsync(); return(CreatedAtAction("GetMainDepDetail", new { id = model.MainDepID }, model)); } catch (Exception ex) { throw ex; } }