Ejemplo n.º 1
0
        public JsonResult GetTopicByAssignment(TopicFind b)
        {
            using (SqlConnection DefaultConnection = new SqlConnection(DBHelper.ConnectionString))
            using (SqlCommand cmd = new SqlCommand("GetTopicByAssignment", DefaultConnection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@AssignmentTypeID", b.AssignmentTypeID);
                cmd.Parameters.AddWithValue("@SubscriptionID", b.SubscriptionId);

                DefaultConnection.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    List<SelectListItem> paresult = new List<SelectListItem>();
                    while (reader.Read())
                    {
                        paresult.Add(new SelectListItem { Value = reader.GetString("TopicID"), Text = reader.GetString("TopicDescription") });
                    }

                    return Json(paresult, JsonRequestBehavior.AllowGet);
                }
            }
        }
Ejemplo n.º 2
0
        public JsonResult SaveSubscriptionDetail(TopicFind b)
        {
            int subscriptionId = b.SubscriptionId;
            int assignmenttypeId = b.AssignmentTypeID;
            int topicId = b.TopicID;
            string createdBy = b.CreatedBy;

            using (var DefaultConnection = DBHelper.DefaultConnection)
            using (var cmd = DefaultConnection.CreateCommand().ForProcedure("SaveDetail"))
            {
                cmd.Parameters.Add("@SubscriptionID", SqlDbType.SmallInt).Value = subscriptionId;
                cmd.Parameters.Add("@TopicID", SqlDbType.SmallInt).Value = topicId;
                cmd.Parameters.Add("@AssignmentTypeId", SqlDbType.SmallInt).Value = assignmenttypeId;
                cmd.Parameters.Add("@CreatedBy", SqlDbType.NVarChar).Value = createdBy;
                try
                {
                    DefaultConnection.Open();
                    cmd.ExecuteNonQuery();

                }
                catch (Exception)
                {
                }
                finally
                {
                    DefaultConnection.Close();
                }
            }

            List<SubscriptionDetails> paresult = new List<SubscriptionDetails>();

            using (var DefaultConnection = DBHelper.DefaultConnection)
            using (var cmd = DefaultConnection.CreateCommand().ForProcedure("GetAssignmentTypeAndName"))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@SubscriptionID", subscriptionId);
                DefaultConnection.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        paresult.Add(new SubscriptionDetails
                        {
                            TopicDescription = reader.GetString("TopicDescription"),
                            AssignmentDescription = reader.GetString("AssignmentDescription"),
                            CreatedBy = reader.GetString("CreatedBy"),
                            CourseTopicID = reader.GetInt32("CourseTopicID") ?? 0,
                            SubscriptionID = reader.GetInt32("SubscriptionID") ?? 0
                        });
                    }
                }

            }

            return Json(paresult, JsonRequestBehavior.AllowGet);
        }
Ejemplo n.º 3
0
        public JsonResult getAssignmentTypeAndName(TopicFind b)
        {
            using (SqlConnection DefaultConnection = new SqlConnection(DBHelper.ConnectionString))
            using (SqlCommand cmd = new SqlCommand("GetAssignmentTypeAndName", DefaultConnection))
            {
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@SubscriptionID", b.SubscriptionId);
                DefaultConnection.Open();

                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    List<SubscriptionDetails> paresult = new List<SubscriptionDetails>();
                    while (reader.Read())
                    {
                        paresult.Add(new SubscriptionDetails
                        {
                            TopicDescription = reader.GetString("TopicDescription"),
                            AssignmentDescription = reader.GetString("AssignmentDescription"),
                            CreatedBy = reader.GetString("CreatedBy"),
                            CourseTopicID = reader.GetInt32("CourseTopicID") ?? 0,
                            SubscriptionID = reader.GetInt32("SubscriptionID") ?? 0,
                            QuizDefinitionID = reader.GetInt32("QuizDefinitionID"),
                            CustomQuizAllowed = reader.GetBoolean("CustomQuizAllowed")??true
                        });
                    }

                    return Json(paresult, JsonRequestBehavior.AllowGet);
                }
            }
        }