public async Task <IActionResult> Create([Bind("ID,Number,Symbol")] Grade grade) { if (ModelState.IsValid) { if (gradeRepository.Create(grade) == true) { await db.SaveChangesAsync(); } return(RedirectToAction(nameof(Index))); } return(View(grade)); }
public async Task <IActionResult> Create([FromBody] Grade grade) { if (String.IsNullOrEmpty(grade.Name)) { return(Ok(new { status = ResultStatus.STATUS_INVALID_INPUT, message = "Tên nghề nghiệp không được để trống" })); } await gradeRepository.Create(grade); return(Ok(new { status = ResultStatus.STATUS_OK, data = grade })); }