public async Task <IActionResult> SubjectAdd(CourseSubjectModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var subject = new CourseSubject(); subject = model.ToEntity(subject); await _courseSubjectService.Insert(subject); return(new NullJsonResult()); }
public async Task <IActionResult> SubjectUpdate(CourseSubjectModel model) { if (!ModelState.IsValid) { return(Json(new DataSourceResult { Errors = ModelState.SerializeErrors() })); } var subject = await _courseSubjectService.GetById(model.Id); subject = model.ToEntity(subject); await _courseSubjectService.Update(subject); return(new JsonResult("")); }
public static CourseSubject ToEntity(this CourseSubjectModel model, CourseSubject destination) { return(model.MapTo(destination)); }
public static CourseSubject ToEntity(this CourseSubjectModel model) { return(model.MapTo <CourseSubjectModel, CourseSubject>()); }