33const userModel = require ( "../models/user" ) ;
44
55class activity {
6- static update = async ( req , res , next ) => {
6+ static subject = async ( req , res , next ) => {
77 try {
88 const currentUser = req . currentUser ;
99 const subject = req . body ;
@@ -25,6 +25,115 @@ class activity {
2525 next ( error ) ;
2626 }
2727 } ;
28+
29+ static subjectGet = async ( req , res , next ) => {
30+ try {
31+ const currentUser = req . currentUser ;
32+
33+ const user = await userModel . findOne ( { _id : currentUser . _id } ) ;
34+
35+ if ( ! user ) {
36+ next ( { code : 404 , message : "User Not Found" } ) ;
37+ return ;
38+ }
39+
40+ res . status ( 200 ) . json ( { data : user . activity . subject } ) ;
41+ } catch ( error ) {
42+ next ( error ) ;
43+ }
44+ } ;
45+
46+ static upcomingexam = async ( req , res , next ) => {
47+ try {
48+ const currentUser = req . currentUser ;
49+ const exams = req . body ;
50+
51+ const user = await userModel . findOne ( { _id : currentUser . _id } ) ;
52+
53+ if ( ! user ) {
54+ next ( { code : 404 , message : "User Not Found" } ) ;
55+ return ;
56+ }
57+
58+ const update = await userModel . updateOne (
59+ { _id : currentUser . _id } ,
60+ { $set : { "activity.upcomingexam" : exams } }
61+ ) ;
62+
63+ res . status ( 200 ) . json ( { update } ) ;
64+ } catch ( error ) {
65+ next ( error ) ;
66+ }
67+ } ;
68+
69+ static seminar = async ( req , res , next ) => {
70+ try {
71+ const currentUser = req . currentUser ;
72+ const seminars = req . body ;
73+
74+ const user = await userModel . findOne ( { _id : currentUser . _id } ) ;
75+
76+ if ( ! user ) {
77+ next ( { code : 404 , message : "User Not Found" } ) ;
78+ return ;
79+ }
80+
81+ const update = await userModel . updateOne (
82+ { _id : currentUser . _id } ,
83+ { $set : { "activity.seminar" : seminars } }
84+ ) ;
85+
86+ res . status ( 200 ) . json ( { update } ) ;
87+ } catch ( error ) {
88+ next ( error ) ;
89+ }
90+ } ;
91+
92+ static workshop = async ( req , res , next ) => {
93+ try {
94+ const currentUser = req . currentUser ;
95+ const workshops = req . body ;
96+
97+ const user = await userModel . findOne ( { _id : currentUser . _id } ) ;
98+
99+ if ( ! user ) {
100+ next ( { code : 404 , message : "User Not Found" } ) ;
101+ return ;
102+ }
103+
104+ const update = await userModel . updateOne (
105+ { _id : currentUser . _id } ,
106+ { $set : { "activity.workshop" : workshops } }
107+ ) ;
108+
109+ res . status ( 200 ) . json ( { update } ) ;
110+ } catch ( error ) {
111+ next ( error ) ;
112+ }
113+ } ;
114+
115+ static competition = async ( req , res , next ) => {
116+ try {
117+ const currentUser = req . currentUser ;
118+ const competitions = req . body ;
119+
120+ const user = await userModel . findOne ( { _id : currentUser . _id } ) ;
121+
122+ if ( ! user ) {
123+ next ( { code : 404 , message : "User Not Found" } ) ;
124+ return ;
125+ }
126+
127+ const update = await userModel . updateOne (
128+ { _id : currentUser . _id } ,
129+ { $set : { "activity.competition" : competitions } }
130+ ) ;
131+
132+ res . status ( 200 ) . json ( { update } ) ;
133+ } catch ( error ) {
134+ next ( error ) ;
135+ }
136+ } ;
28137}
29138
30139module . exports = activity ;
0 commit comments