public string ResultSMS(DataTable dt) { string SMSResponse = string.Empty; foreach (DataRow dr in dt.Rows) { //var names = dr.StudentName.Trim().Split(' '); //string FirstName = names[0]; if (Convert.ToBoolean(dr["IsPresent"]) == true) { if (dr["MobileNumber"].ToString() != string.Empty) { string MobileNo = dr["MobileNumber"].ToString(); string DeviceToken = dr["DeviceToken"].ToString(); string Message = string.Format(@"Dear {0},you got {1}/{2} ({3}%) in {4} of {5} attempts in phy,chem,bio(corr./incorr) are ({6}/{7}),({8}/{9}),({10}/{11}) respectively.", dr["FirstName"], dr["TotalMarksObtained"], dr["TotalMarks"], dr["Percentage"], dr["TestName"], dr["StartDate"].ToString().ConvertDateTimeToString(), dr["Physics_Right"], dr["Physics_Wrong"], dr["Chemistry_Right"], dr["Chemistry_Wrong"], dr["Biology_Right"], dr["Biology_Wrong"]); SMSResponse = DSMSGeneric.SendSingleSMS(MobileNo, Message); if (!string.IsNullOrEmpty(DeviceToken)) { SMSResponse = DSMSGeneric.SendAndroidNotification(DeviceToken, "Result Declared", Message); } } if (dr["FatherMobile"].ToString() != string.Empty) { string MobileNo = dr["FatherMobile"].ToString(); string Message = string.Format(@"Dear Parents,{0} got {1}/{2} ({3}%) in {4} of {5} attempts in phy,chem,bio(corr./incorr) are ({6}/{7}),({8}/{9}),({10}/{11}) respectively.", dr["FirstName"], dr["TotalMarksObtained"], dr["TotalMarks"], dr["Percentage"], dr["TestName"], dr["StartDate"].ToString().ConvertDateTimeToString(), dr["Physics_Right"], dr["Physics_Wrong"], dr["Chemistry_Right"], dr["Chemistry_Wrong"], dr["Biology_Right"], dr["Biology_Wrong"]); SMSResponse = DSMSGeneric.SendSingleSMS(MobileNo, Message); } } else if (Convert.ToBoolean(dr["IsPresent"]) == false) { if (dr["MobileNumber"].ToString() != string.Empty) { string MobileNo = dr["MobileNumber"].ToString(); string DeviceToken = dr["DeviceToken"].ToString(); string Message = string.Format(@"Dear {0},you was absent in {1} of {2}", dr["FirstName"], dr["TestName"], dr["StartDate"].ToString().ConvertDateTimeToString()); SMSResponse = DSMSGeneric.SendSingleSMS(MobileNo, Message); if (!string.IsNullOrEmpty(DeviceToken)) { SMSResponse = DSMSGeneric.SendAndroidNotification(DeviceToken, "Result Declared!", Message); } } if (dr["FatherMobile"].ToString() != string.Empty) { string MobileNo = dr["FatherMobile"].ToString(); string Message = string.Format(@"Dear Parents,{0} was absent in {1} of {2}", dr["FirstName"], dr["TestName"], dr["StartDate"].ToString().ConvertDateTimeToString()); SMSResponse = DSMSGeneric.SendSingleSMS(MobileNo, Message); } } } return(SMSResponse); }
public ForgetPassword ForgetPassword(ForgetPassword objForgetPassword) { string MobileNo; if (objForgetPassword.Action == "SendOTP") { string strQuery = string.Format("Select MobileNumber from Student where EnrollmentNo='{0}'", objForgetPassword.UserName); MobileNo = Convert.ToString(DGeneric.GetValue(strQuery)); if (string.IsNullOrEmpty(MobileNo)) { MobileNo = Convert.ToString(DGeneric.GetValue(String.Format("select Mobile from Users where UserName='******'", objForgetPassword.UserName))); if (string.IsNullOrEmpty(MobileNo)) { objForgetPassword.ConfirmOTP = "0"; } else { Random rand = new Random(); objForgetPassword.ConfirmOTP = rand.Next(0, 999999).ToString("D6"); string strMessage = "Your OTP is: " + objForgetPassword.ConfirmOTP; string response = DSMSGeneric.SendSingleSMS("8871171445", strMessage); objForgetPassword.UserTypeID = 1; } } else { Random rand = new Random(); objForgetPassword.ConfirmOTP = rand.Next(0, 999999).ToString("D6"); string strMessage = "Your OTP is: " + objForgetPassword.ConfirmOTP; string response = DSMSGeneric.SendSingleSMS("8871171445", strMessage); objForgetPassword.UserTypeID = 2; } } else if (objForgetPassword.Action == "UpdatePassword") { if (objForgetPassword.UserTypeID == 1) { string strQuery = string.Format("update users set UserPassword='******' where UserName='******'", objForgetPassword.NewPassword, objForgetPassword.UserName); DGeneric.ExecQuery(strQuery); objForgetPassword.Status = "Success"; } else if (objForgetPassword.UserTypeID == 2) { int StudentID = Convert.ToInt32(DGeneric.GetValue(String.Format("select StudentID from Student where EnrollmentNo='{0}'", objForgetPassword.UserName))); string strQuery = string.Format("update StudentAccount set Password='******' where StudentID='{1}'", objForgetPassword.NewPassword, StudentID); DGeneric.ExecQuery(strQuery); objForgetPassword.Status = "Success"; } } return(objForgetPassword); }
public string AddUpdateNotification(List <NotificationViewModel> objList) { string response = string.Empty; foreach (var objNotification in objList) { response = DSMSGeneric.SendAndroidNotification(objNotification.DeviceToken, objNotification.Title, objNotification.Description); List <SqlParameter> sqlParameterList = new List <SqlParameter>(); sqlParameterList.Add(new SqlParameter("NotificationID", objNotification.NotificationID)); sqlParameterList.Add(new SqlParameter("ReciverID", objNotification.ReciverID)); sqlParameterList.Add(new SqlParameter("NotificationDate", Convert.ToDateTime(objNotification.NotificationDate))); sqlParameterList.Add(new SqlParameter("Title", !string.IsNullOrEmpty(objNotification.Title) ? objNotification.Title : string.Empty)); sqlParameterList.Add(new SqlParameter("Description", !string.IsNullOrEmpty(objNotification.Description) ? objNotification.Description : string.Empty)); sqlParameterList.Add(new SqlParameter("ImageURL", !string.IsNullOrEmpty(objNotification.ImageURL) ? objNotification.ImageURL : string.Empty)); sqlParameterList.Add(new SqlParameter("RedirectToURL", !string.IsNullOrEmpty(objNotification.RedirectToURL) ? objNotification.RedirectToURL : string.Empty)); sqlParameterList.Add(new SqlParameter("IsRead", objNotification.IsRead)); response = DGeneric.RunSP_ExecuteNonQuery("sp_AddUpdateNotification", sqlParameterList); } return(response); }
public string AddEligibleStudent(List <EligibleStudentViewModel> EligibleStudentData) { string response = string.Empty; foreach (var item in EligibleStudentData) { if (item.TestStatusID == 1 && item.IsMessageSend == false) { string TestName = item.TestName; string StartDate = item.StartDate; string EndDate = item.EndDate; string StudentName = item.StudentName; string MobileNumber = item.MobileNumber; string FatherMobileNo = item.FatherMobileNo; string DeviceToken = item.DeviceToken; string StudentMessage = string.Format("Dear {0}, you are assigned {1}. You can attempt test from {2} to {3}.", StudentName, TestName, StartDate, EndDate); response = DSMSGeneric.SendSingleSMS(MobileNumber, StudentMessage); if (!string.IsNullOrEmpty(DeviceToken)) { response = DSMSGeneric.SendAndroidNotification(DeviceToken, "Test Alert!", StudentMessage); } } } var dt = new DataTable(); dt.Columns.Add("OnlineTestID", typeof(int)); dt.Columns.Add("StudentID", typeof(int)); dt.Columns.Add("TestStatusID", typeof(int)); dt.Columns.Add("IsMessageSend", typeof(bool)); foreach (var item in EligibleStudentData) { dt.Rows.Add(item.OnlineTestID, item.StudentID, item.TestStatusID, item.IsMessageSend); } List <SqlParameter> sqlParameterList = new List <SqlParameter>(); sqlParameterList.Add(new SqlParameter("@EligibleStudentDetails", dt)); response = DGeneric.RunSP_ExecuteNonQuery("sp_AddEligibleStudent", sqlParameterList); return(response); }