Пример #1
0
        //takes in classId
        public ActionResult AddAssignment(int id)
        {
            var assignment = new AssignmentView();
            var newAssignment = new Assignment();
            assignment.NewAssignment = newAssignment;
               assignment.NewAssignment.ClassId = id;
            assignment.ClassName = _teacherRepository.GetCourseById(id).Name;

             return View(assignment);
        }
Пример #2
0
        public void EditAssignment(Assignment assignment)
        {
            using (SqlConnection cn = new SqlConnection(Config.GetConnectionString()))
               {
               var p = new DynamicParameters();
               p.Add("@AssignmentId", assignment.AssignmentId);
               p.Add("@ClassId", assignment.ClassId);
               p.Add("@Name",assignment.Name);
               p.Add("@PossiblePoints", assignment.PossiblePoints);
               p.Add("@DueDate", assignment.DueDate);
               p.Add("@Description", assignment.Description);

               cn.Execute("AssignmentUpdate", p, commandType: CommandType.StoredProcedure);
               }
        }
Пример #3
0
        public void CreateAssignment(Assignment assignment)
        {
            using (SqlConnection cn = new SqlConnection(Config.GetConnectionString()))
               {
               var p = new DynamicParameters();
               p.Add("@ClassId", assignment.ClassId);
               p.Add("@Name", assignment.Name);
               p.Add("@PossiblePoints", assignment.PossiblePoints);
               p.Add("@DueDate", assignment.DueDate);
               p.Add("@Description", assignment.Description);
               p.Add("@AssignmentId", dbType: DbType.Int32, direction: ParameterDirection.Output);

               cn.Execute("AssignmentInsert", p, commandType: CommandType.StoredProcedure);

               assignment.AssignmentId = p.Get<int>("@AssignmentId");
               }
        }
Пример #4
0
        //assignment id  How do i return a single item with Dapper?
        public Assignment GetAssignment(int assignmentId)
        {
            Assignment assignment = null;

               using (var cn = new SqlConnection(Config.GetConnectionString()))
               {
               var cmd = new SqlCommand("AssignmentGetById", cn);
               cmd.CommandType = CommandType.StoredProcedure;

               cmd.Parameters.AddWithValue("@AssignmentId", assignmentId);

               cn.Open();

               using (var dr = cmd.ExecuteReader())
               {
                   if (dr.Read())
                   {
                       assignment = new Assignment()
                       {
                           AssignmentId = (int)dr["AssignmentId"],
                           ClassId = (int)dr["ClassId"],
                           Name = dr["Name"].ToString(),
                           PossiblePoints = (int)dr["PossiblePoints"],
                           DueDate = (DateTime)dr["DueDate"],
                           Description = dr["Description"].ToString()
                       };
                   }
               }
               }

               return assignment;
        }