public Result AssignClass(int teacherId, int classId) { Class c = null; if (_teacherGateway.FindById(teacherId) == null) { return(Result.Failure(Status.BadRequest, "Unknown teacher.")); } if (classId != 0 && (c = _classGateway.FindById(classId)) == null) { return(Result.Failure(Status.BadRequest, "Unknown class.")); } if (c != null && c.TeacherId != 0 && c.TeacherId != teacherId) { return(Result.Failure(Status.BadRequest, "Class already assigned.")); } _teacherGateway.AssignClass(teacherId, classId); return(Result.Success(Status.Ok)); }
public async Task <IActionResult> AssignClass(int id, [FromBody] AssignClassViewModel model) { Result result = await _teacherGateway.AssignClass(id, model.ClassId); return(this.CreateResult(result)); }