public ActionResult AddSubject(int subject, List <int> categoryId, string topicName, string description) { InviteModel newInvite = new InviteModel(); newInvite.TeacherId = null; newInvite.StudentId = User.Identity.GetUserId(); newInvite.Type = 1; newInvite.SubjectId = Convert.ToInt32(subject); int token = newInvite.Save(); if (token == -55) { throw new HttpException(404, "Some description"); } else { ResearchTopics topic = new ResearchTopics(); topic.Topic = topicName; topic.SubjectId = subject; topic.ShortDescription = description; topic.UserId = User.Identity.GetUserId(); topic.ResearchIds = categoryId; topic.Save(); foreach (int id in categoryId) { MailSender(id, subject); } } return(null); }
internal void saveTopic(ResearchTopics researchTopics) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("sp_SaveTopic", sqlConnection)) { try { sqlConnection.Open(); command.CommandType = CommandType.StoredProcedure; if (researchTopics.Id == null) { command.Parameters.AddWithValue("@Id", DBNull.Value); } else { command.Parameters.AddWithValue("@Id", researchTopics.Id); } command.Parameters.AddWithValue("@ShortDescription", researchTopics.ShortDescription); command.Parameters.AddWithValue("@Topic", researchTopics.Topic); command.Parameters.AddWithValue("@UserId", researchTopics.UserId); command.Parameters.AddWithValue("@SubjectId", researchTopics.SubjectId); researchTopics.Id = Convert.ToInt32(command.ExecuteScalar()); } catch (Exception ex) { throw ex; } } } saveAreas(researchTopics.ResearchIds, Convert.ToInt32(researchTopics.Id)); }
internal List <ResearchTopics> getTopicById(int id) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("sp_GetTopic", sqlConnection)) { try { sqlConnection.Open(); command.CommandType = CommandType.StoredProcedure; command.Parameters.AddWithValue("@Id", id); SqlDataReader rdr = command.ExecuteReader(); List <ResearchTopics> topicList = new List <ResearchTopics>(); while (rdr.Read()) { ResearchTopics topic = new ResearchTopics(); topic.Id = Convert.ToInt32(rdr["Id"]); topic.ShortDescription = rdr["ShortDescription"].ToString(); topic.Topic = rdr["Topic"].ToString(); topic.UserId = rdr["UserId"].ToString(); topic.SubjectId = Convert.ToInt32(rdr["SubjectId"]); topicList.Add(topic); } return(topicList); } catch (Exception ex) { throw ex; } } } }
public ActionResult SaveSkills(List <int> moduleIds, List <int> interestsIds) { TeacherSkillViewModel skill = new TeacherSkillViewModel(); skill.Save(User.Identity.GetUserId(), moduleIds); ResearchTopics.SaveProfileAreas(interestsIds, User.Identity.GetUserId()); return(null); }
internal List <ResearchTopics> getTopicByKeywordByInterestId(int?interestId, string keyword) { using (SqlConnection sqlConnection = new SqlConnection(connectionString)) { using (SqlCommand command = new SqlCommand("sp_GetTopicByKeywordByInterestId", sqlConnection)) { try { sqlConnection.Open(); command.CommandType = CommandType.StoredProcedure; if (String.IsNullOrEmpty(keyword)) { command.Parameters.AddWithValue("@Keyword", DBNull.Value); } else { command.Parameters.AddWithValue("@Keyword", keyword); } if (interestId == null) { command.Parameters.AddWithValue("@InterestId", DBNull.Value); } else { command.Parameters.AddWithValue("@InterestId", interestId); } SqlDataReader rdr = command.ExecuteReader(); List <ResearchTopics> topicList = new List <ResearchTopics>(); while (rdr.Read()) { ResearchTopics topic = new ResearchTopics(); topic.Id = Convert.ToInt32(rdr["Id"]); topic.ShortDescription = rdr["ShortDescription"].ToString(); topic.Topic = rdr["Topic"].ToString(); topic.UserId = rdr["UserId"].ToString(); topic.SubjectId = Convert.ToInt32(rdr["SubjectId"]); topicList.Add(topic); } return(topicList); } catch (Exception ex) { throw ex; } } } }
public ActionResult FindStudentPartial(string keyword, int?interestId) { var researchTopics = ResearchTopics.GetTopicByInterestId(interestId, keyword); return(PartialView(researchTopics)); }