public static SubjectViewModel ToViewModel(this Subject model) { var viewModel = new SubjectViewModel(); viewModel.InjectFrom(model); return viewModel; }
public ActionResult Add(SubjectViewModel model) { if (ModelState.IsValid) { var teacherID = this.HttpContext.Cache.GetTeacherID(); if (teacherID != null) { var subject = model.ToModel(); this._subjectManager.AddSubjectForTeacher(subject, teacherID); return this.Json(new { success = true }); } return HttpNotFound(); } return this.Json(new {success = false}); }