Esempio n. 1
0
        public JsonResult ARAction(string Approve = "0", string StudentID = "", string CourseID = "", string Remarks = "", string CMRID = "0")
        {
            string Code = string.Empty, Message = string.Empty, Error = string.Empty;

            try
            {
                InstituteRepository _objRepo = new InstituteRepository();
                DataSet             _ds      = _objRepo.APPROVE_REJECT_PHASE2_ALLOTED_STUDENTS(Session["InstituteID"].ToString(), StudentID, CourseID, Remarks, Approve, CMRID);
                if (_ds != null)
                {
                    if (_ds.Tables[0].Rows.Count > 0)
                    {
                        if (Approve == "1")
                        {
                            Message = "Student has been approved successfully!";
                            DataRow   _dr           = _ds.Tables[0].Rows[0];
                            SendEmail _objseedemail = new SendEmail();

                            string strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername"];
                            #region Code to send mails simultaneously in a loop (By Amit: 14-06-2019 11:45 AM)
                            if (System.Web.HttpContext.Current.Application["UserCountForMail"] == null)
                            {
                                System.Web.HttpContext.Current.Application["UserCountForMail"] = 1;
                            }
                            else
                            {
                            }
                            int UserCountForMail = Convert.ToInt32(System.Web.HttpContext.Current.Application["UserCountForMail"]);
                            if (UserCountForMail < 4)
                            {
                                UserCountForMail++;
                            }
                            else
                            {
                                UserCountForMail = 1;
                            }
                            if (System.Web.HttpContext.Current.Application["UserCountForMail"] == null)
                            {
                                System.Web.HttpContext.Current.Application["UserCountForMail"] = 1;
                            }

                            if (UserCountForMail == 1)
                            {
                                strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername1"];
                            }
                            else if (UserCountForMail == 2)
                            {
                                strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername2"];
                            }
                            else if (UserCountForMail == 3)
                            {
                                strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername3"];
                            }
                            else if (UserCountForMail == 4)
                            {
                                strform = System.Configuration.ConfigurationManager.AppSettings["Emailusername4"];
                            }

                            #endregion
                            string        Subject  = "Congratulations! The institute has accepted your candidature.";
                            StringBuilder MailBody = new StringBuilder();
                            MailBody.Append("<br/>Dear " + _dr["StudentName"].ToString() + ",<br/>");
                            MailBody.Append("<br/>Congratulations! The institute has accepted your candidature. Please login to your dashboard and accept the offer to Study in India.");
                            MailBody.Append("<br/>To check your results Login at : <a href='https://www.studyinindia.gov.in/admission/login'>https://www.studyinindia.gov.in/admission/login</a><br/>");
                            MailBody.Append("<br/><br/><br/>Regards,<br/>");
                            MailBody.Append("Study in India Team<br/>");
                            string bcc = "";
                            string cc  = "";
                            _objseedemail.SendEmailInBackgroundThread(strform, _dr["Email"].ToString(), bcc, cc, Subject, MailBody.ToString(), "", true);
                        }
                        else
                        {
                            Message = "Student has been rejected successfully!";
                        }
                        Code = "success";
                    }
                    else
                    {
                        Message = "Error from server side. Kindly refresh the page and try again.!";
                        Code    = "servererror";
                    }
                }
            }
            catch (NullReferenceException)
            {
                Code    = "error";
                Message = "Your session has been expired. Kindly refresh and try again.";
            }
            catch (Exception)
            {
                Code    = "error";
                Message = "Error from server side. Kindly refresh and try again.";
            }

            return(Json(new
            {
                c = Code,
                m = Message
            },
                        JsonRequestBehavior.AllowGet
                        ));
        }