Commit fd3bd858e89b190fbc5c88c5369ebc500629b27a
1 parent
86efd9bd
removed empty function
Showing
1 changed file
with
105 additions
and
113 deletions
400-SOURCECODE/AIAHTML5.API/Controllers/ForgotUserController.cs
1 | -using System; | |
2 | -using System.Collections.Generic; | |
3 | -using System.Linq; | |
4 | -using System.Net; | |
5 | -using System.Net.Http; | |
6 | -using System.Web.Http; | |
7 | -using AIAHTML5.API.Constants; | |
8 | -using log4net; | |
9 | -using Newtonsoft.Json; | |
10 | -using Newtonsoft.Json.Linq; | |
11 | -using AIAHTML5.API.Models; | |
12 | -using AIAHTML5.API.Utility; | |
13 | -using System.Collections; | |
14 | -using System.Data.SqlClient; | |
15 | - | |
16 | -namespace AIAHTML5.API.Controllers | |
17 | -{ | |
18 | - public class ForgotUserController : ApiController | |
19 | - { | |
20 | - // GET api/<controller> | |
21 | - public IEnumerable<string> Get() | |
22 | - { | |
23 | - return new string[] { "value1", "value2" }; | |
24 | - } | |
25 | - | |
26 | - // GET api/<controller>/5 | |
27 | - public string Get(int id) | |
28 | - { | |
29 | - return "value"; | |
30 | - } | |
31 | - | |
32 | - public HttpResponseMessage Post([FromBody]JObject userInfo) | |
33 | - { | |
34 | - ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
35 | - logger.Debug("inside POST in ForgotUserController for emailId = " + userInfo["emailId"]); | |
36 | - try | |
37 | - { | |
38 | - dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo); | |
39 | - | |
40 | - if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND) | |
41 | - { | |
42 | - //logger.Debug("inside if in ForgotUserController userData.loginId= " + userData.LoginId); | |
43 | - bool isMailSent = false; | |
44 | - | |
45 | - logger.Debug("1. inside if in ForgotUserController userDetails= " + userData.ToString()); | |
46 | - | |
47 | - if (Convert.ToBoolean(userInfo["isMailForForgotPassword"])) | |
48 | - { | |
49 | - if (Convert.ToBoolean(userInfo["unblockUser"])) | |
50 | - { | |
51 | - logger.Debug("2. unblockUser= " + Convert.ToBoolean(userInfo["unblockUser"])); | |
52 | - isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"]), Convert.ToBoolean(userInfo["unblockUser"])); | |
53 | - } | |
54 | - else | |
55 | - { | |
56 | - logger.Debug("2. isMailForForgotPassword= " + Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
57 | - isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
58 | - } | |
59 | - | |
60 | - } | |
61 | - else | |
62 | - { | |
63 | - logger.Debug("3. isMailForForgotPassword= " + Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
64 | - | |
65 | - isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
66 | - } | |
67 | - logger.Debug("isMailSent= " + isMailSent); | |
68 | - if (isMailSent) | |
69 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_SENT) }; | |
70 | - else | |
71 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT) }; | |
72 | - } | |
73 | - else | |
74 | - { | |
75 | - logger.Debug("inside else in ForgotUserController userData= " + userData); | |
76 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.USER_NOT_FOUND) }; | |
77 | - } | |
78 | - } | |
79 | - catch (SqlException e) | |
80 | - { | |
81 | - | |
82 | - logger.Fatal("SqlException occured for emailId =" + userInfo["emailId"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
83 | - | |
84 | - ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
85 | - string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; | |
86 | - string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
87 | - UserUtility.SendEmail(userInfo, supportMailList, "", mailSubject, mailBody); | |
88 | - | |
89 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; | |
90 | - } | |
91 | - catch (Exception e) | |
92 | - { | |
93 | - logger.Fatal("Exception occured for emailId =" + userInfo["emailId"].ToString()+ "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
94 | - | |
95 | - ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
96 | - string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; | |
97 | - string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
98 | - UserUtility.SendEmail(userInfo, supportMailList, "", mailSubject, mailBody); | |
99 | - return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; | |
100 | - | |
101 | - } | |
102 | - } | |
103 | - | |
104 | - // PUT api/<controller>/5 | |
105 | - public void Put(int id, [FromBody]string value) | |
106 | - { | |
107 | - } | |
108 | - | |
109 | - // DELETE api/<controller>/5 | |
110 | - public void Delete(int id) | |
111 | - { | |
112 | - } | |
113 | - } | |
1 | +using System; | |
2 | +using System.Collections.Generic; | |
3 | +using System.Linq; | |
4 | +using System.Net; | |
5 | +using System.Net.Http; | |
6 | +using System.Web.Http; | |
7 | +using AIAHTML5.API.Constants; | |
8 | +using log4net; | |
9 | +using Newtonsoft.Json; | |
10 | +using Newtonsoft.Json.Linq; | |
11 | +using AIAHTML5.API.Models; | |
12 | +using AIAHTML5.API.Utility; | |
13 | +using System.Collections; | |
14 | +using System.Data.SqlClient; | |
15 | + | |
16 | +namespace AIAHTML5.API.Controllers | |
17 | +{ | |
18 | + public class ForgotUserController : ApiController | |
19 | + { | |
20 | + // GET api/<controller> | |
21 | + public IEnumerable<string> Get() | |
22 | + { | |
23 | + return new string[] { "value1", "value2" }; | |
24 | + } | |
25 | + | |
26 | + // GET api/<controller>/5 | |
27 | + public string Get(int id) | |
28 | + { | |
29 | + return "value"; | |
30 | + } | |
31 | + | |
32 | + public HttpResponseMessage Post([FromBody]JObject userInfo) | |
33 | + { | |
34 | + ILog logger = log4net.LogManager.GetLogger((System.Reflection.MethodBase.GetCurrentMethod().DeclaringType)); | |
35 | + logger.Debug("inside POST in ForgotUserController for emailId = " + userInfo["emailId"]); | |
36 | + try | |
37 | + { | |
38 | + dynamic userData = AIAHTML5.API.Models.Users.GetUserByEmail(userInfo); | |
39 | + | |
40 | + if (Convert.ToString(userData) != AIAConstants.USER_NOT_FOUND) | |
41 | + { | |
42 | + //logger.Debug("inside if in ForgotUserController userData.loginId= " + userData.LoginId); | |
43 | + bool isMailSent = false; | |
44 | + | |
45 | + logger.Debug("1. inside if in ForgotUserController userDetails= " + userData.ToString()); | |
46 | + | |
47 | + if (Convert.ToBoolean(userInfo["isMailForForgotPassword"])) | |
48 | + { | |
49 | + if (Convert.ToBoolean(userInfo["unblockUser"])) | |
50 | + { | |
51 | + logger.Debug("2. unblockUser= " + Convert.ToBoolean(userInfo["unblockUser"])); | |
52 | + isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"]), Convert.ToBoolean(userInfo["unblockUser"])); | |
53 | + } | |
54 | + else | |
55 | + { | |
56 | + logger.Debug("2. isMailForForgotPassword= " + Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
57 | + isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
58 | + } | |
59 | + | |
60 | + } | |
61 | + else | |
62 | + { | |
63 | + logger.Debug("3. isMailForForgotPassword= " + Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
64 | + | |
65 | + isMailSent = AIAHTML5.API.Models.UserUtility.SendEmail(userData, Convert.ToBoolean(userInfo["isMailForForgotPassword"])); | |
66 | + } | |
67 | + logger.Debug("isMailSent= " + isMailSent); | |
68 | + if (isMailSent) | |
69 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_SENT) }; | |
70 | + else | |
71 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.MAIL_NOT_SENT) }; | |
72 | + } | |
73 | + else | |
74 | + { | |
75 | + logger.Debug("inside else in ForgotUserController userData= " + userData); | |
76 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.OK, Content = new StringContent(AIAConstants.USER_NOT_FOUND) }; | |
77 | + } | |
78 | + } | |
79 | + catch (SqlException e) | |
80 | + { | |
81 | + | |
82 | + logger.Fatal("SqlException occured for emailId =" + userInfo["emailId"].ToString() + "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
83 | + | |
84 | + ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
85 | + string mailSubject = AIAConstants.SQL_CONNECTION_ERROR_MAIL_SUBJECT; | |
86 | + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
87 | + UserUtility.SendEmail(userInfo, supportMailList, "", mailSubject, mailBody); | |
88 | + | |
89 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.SQL_CONNECTION_ERROR) }; | |
90 | + } | |
91 | + catch (Exception e) | |
92 | + { | |
93 | + logger.Fatal("Exception occured for emailId =" + userInfo["emailId"].ToString()+ "Exception= " + e.Message + ", STACKTRACE: " + e.StackTrace); | |
94 | + | |
95 | + ArrayList supportMailList = UserUtility.GetSupportMailList(); | |
96 | + string mailSubject = AIAConstants.EXCEPTION_IN_AIAHTML5_MAIL_SUBJECT; | |
97 | + string mailBody = "MESSAGE: " + e.Message + ", STACKTRACE: " + e.StackTrace; | |
98 | + UserUtility.SendEmail(userInfo, supportMailList, "", mailSubject, mailBody); | |
99 | + return new HttpResponseMessage { StatusCode = HttpStatusCode.InternalServerError, Content = new StringContent(AIAConstants.EXCEPTION_OCCURED) }; | |
100 | + | |
101 | + } | |
102 | + } | |
103 | + | |
104 | + | |
105 | + } | |
114 | 106 | } |
115 | 107 | \ No newline at end of file | ... | ... |