public void AddToRoster(RosterAddRequest request) { using (var cn = new SqlConnection(Config.GetConnectionString())) { var p = new DynamicParameters(); p.Add("@RosterId", dbType: DbType.Int32, direction: ParameterDirection.Output); p.Add("@UserId", request.UserId); p.Add("@ClassId", request.ClassId); cn.Execute("RosterInsert", p, commandType: CommandType.StoredProcedure); request.RosterId = p.Get<int>("@RosterId"); } }
public ActionResult AddStudent(string userId, int classId) { var uberModel = new UberRoster(); var addRequest = new RosterAddRequest(); addRequest.UserId = userId; // addRequest.RosterId = rosterId; addRequest.ClassId = classId; _rosterRepository.AddToRoster(addRequest); uberModel.CourseName = _teacherRepository.GetCourseById(classId).Name; uberModel.ClassId = classId; uberModel.EnrolledStudents = _rosterRepository.GetStudentsEnrolledIn(classId); uberModel.SearchResults = new List<RosterSearchRecord>(); uberModel.SearchRequest = new RosterSearchRequest(); return View("ClassRoster", uberModel); }