示例#1
0
        private void sendMail(login_table item, string firstName, string password)
        {
            string smsg = string.Format("Dear {0},<br/> Your Registration has been sucessfully done.", firstName);

            smsg += string.Format("Your User ID : {0},<br/>Your Password: {1}", item.Id, password);
            smsg += "<br/>Please login with your email-id or UserId.<br/> Thank you <br/> IPTSE Admin.";
            try
            {
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(new MailAddress(item.email));
                message.From       = new MailAddress("*****@*****.**");
                message.Subject    = "IPTSE Registration Confirmation Mail.";
                message.Body       = smsg;
                message.IsBodyHtml = true;
                SmtpClient client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Port           = 80;
                client.Host           = "smtpout.asia.secureserver.net";
                NetworkCredential nc = new NetworkCredential("*****@*****.**", "Iptse@2018");
                client.EnableSsl             = false;
                client.UseDefaultCredentials = true;
                client.Credentials           = nc;
                client.Send(message);
            }
            catch (Exception ex)
            {
                ViewBag.ErrorMessage = "Unable to send mail. Please contact support team for regisration confirmation";
            }
        }
示例#2
0
        // POST: IPTSELogin/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for
        // more details see https://go.microsoft.com/fwlink/?LinkId=317598.
        //[HttpPost]
        //[ValidateAntiForgeryToken]
        public ActionResult Createpassword(login_table login_table)
        {
            if (ModelState.IsValid)
            {
                //login_table.Id = Int32.Parse(Session["createpass"].ToString());
                try
                {
                    login_table.Id    = login_table.Id;
                    login_table.email = login_table.email;
                    byte[] encode = new byte[login_table.password.Length];
                    encode = System.Text.Encoding.UTF8.GetBytes(login_table.password);
                    login_table.password   = Convert.ToBase64String(encode);
                    login_table.Login_type = "Individual";
                    db1.login_table.Add(login_table);
                    db1.SaveChanges();
                    //TempData["Message"] = "Password Created Successfully. Login To Continue..";
                    return(RedirectToAction("Login", "IPTSELogin"));
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = "Already Created! Please go through Forgot Password!";
                    return(View());
                }
            }

            return(View());
        }
示例#3
0
        public string Createpassword(login_table login_table)
        {
            string returMsg = string.Empty;

            if (ModelState.IsValid)
            {
                //login_table.Id = Int32.Parse(Session["createpass"].ToString());
                try
                {
                    login_table.Id    = login_table.Id;
                    login_table.email = login_table.email;
                    byte[] encode = new byte[login_table.password.Length];
                    encode = System.Text.Encoding.UTF8.GetBytes(login_table.password);
                    login_table.password   = Convert.ToBase64String(encode);
                    login_table.Login_type = "Individual";
                    db1.login_table.Add(login_table);
                    db1.SaveChanges();
                    returMsg = "Success";
                }
                catch (Exception ex)
                {
                    ViewBag.ErrorMessage = "Contact Support team. Registration process failed for userid - " + login_table.Id;
                    returMsg             = ViewBag.ErrorMessage;
                    return(returMsg);
                }
            }
            else
            {
                returMsg = "Contact Support team. Login Creation process failed for userid - " + login_table.Id;
            };

            return(returMsg);
        }
        public IHttpActionResult isValidLogin(login_table adminLogin)  //admin login
        {
            login_table admin = db.login_table.Where(x => x.login_id == adminLogin.login_id && x.login_password == adminLogin.login_password).FirstOrDefault();

            if (admin != null)
            {
                return(Ok(admin));
            }
            return(NotFound());
        }
示例#5
0
        public ActionResult Process()
        {
            ViewBag.Message = string.Empty;
            if (Session["StudentDetail"] != null)
            {
                try
                {
                    List <IPTSE_Reg_table> student_Details = new List <IPTSE_Reg_table>();
                    student_Details = Session["StudentDetail"] as List <IPTSE_Reg_table>;
                    foreach (IPTSE_Reg_table item in student_Details)
                    {
                        if (db.IPTSE_Reg_table.Count(c => c.email == item.email) > 0)
                        {
                            ViewBag.Message += "Email-id " + item.email + " already registred. Registration skiiped for this email-id. </br>";
                        }
                        else
                        {
                            db.IPTSE_Reg_table.Add(item);
                            db.SaveChanges();
                            var         lstId       = db.IPTSE_Reg_table.OrderByDescending(t => t.Id).Select(t1 => t1.Id).FirstOrDefault();
                            login_table login_table = new login_table();
                            login_table.Id         = lstId;
                            login_table.email      = item.email;
                            login_table.Login_type = "Individual";
                            var password = item.first_name + item.dob.ToString("_MMyyyy");
                            login_table.password = password;
                            var message = Createpassword(login_table);
                            if (message == "Success")
                            {
                                sendMail(login_table, item.first_name, password);
                            }
                            else
                            {
                                ViewBag.Message = message;
                            }
                        }
                    }

                    if (string.IsNullOrEmpty(ViewBag.Message))
                    {
                        ViewBag.Message = "All Registration are completed successfully. Please proceed for Payment.";
                    }
                }
                catch (DbEntityValidationException entityException)
                {
                    var validationerror = entityException.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault();
                    ViewBag.Message = validationerror.PropertyName + " " + validationerror.ErrorMessage;
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.InnerException.Message;
                }
            }
            return(View("BulkReg"));
        }
示例#6
0
        public IHttpActionResult verifyDoctor(login_table doctorCheck)
        {
            doctor_data doctor = db.doctor_data.Where(doc => doc.doctor_id == doctorCheck.login_id && doc.password == doctorCheck.login_password).FirstOrDefault();

            doctor.speciality_data = null;
            if (doctor != null)
            {
                return(Ok(doctor));
            }
            return(NotFound());
        }
        public decimal InsertSchool(SchoolRegistrationModel schoolRegistrationModel)
        {
            IPTSE_School_Reg_table _schoolRegistration = new IPTSE_School_Reg_table();
            login_table            _objLoginTable      = new login_table();
            decimal newIdentityValue = -1;

            using (var objContext = new IPTSEDBEntities())
            {
                using (var dbcxtransaction = objContext.Database.BeginTransaction())
                {
                    try
                    {
                        _schoolRegistration.institution_name        = schoolRegistrationModel.institution_name;
                        _schoolRegistration.principal_director_name = schoolRegistrationModel.principal_director_name;
                        _schoolRegistration.branch_name             = schoolRegistrationModel.branch_name;
                        _schoolRegistration.institution_type        = schoolRegistrationModel.institution_type;
                        _schoolRegistration.addr1                  = schoolRegistrationModel.addr1;
                        _schoolRegistration.addr2                  = schoolRegistrationModel.addr2;
                        _schoolRegistration.city                   = schoolRegistrationModel.city;
                        _schoolRegistration.state                  = schoolRegistrationModel.state;
                        _schoolRegistration.state                  = schoolRegistrationModel.state;
                        _schoolRegistration.zipcode                = schoolRegistrationModel.zipcode;
                        _schoolRegistration.country                = schoolRegistrationModel.country;
                        _schoolRegistration.institution_contact    = schoolRegistrationModel.institution_contact;
                        _schoolRegistration.institution_email      = schoolRegistrationModel.institution_email;
                        _schoolRegistration.contact_person_name    = schoolRegistrationModel.contact_person_name;
                        _schoolRegistration.contact_person_contact = schoolRegistrationModel.contact_person_contact;
                        _schoolRegistration.contact_person_email   = schoolRegistrationModel.contact_person_email;
                        _schoolRegistration.information_source     = schoolRegistrationModel.information_source;
                        _schoolRegistration.Created_Date           = DateTime.Now;
                        //_schoolRegistration.Updated_Date = DateTime.Now;
                        objContext.IPTSE_School_Reg_table.Add(_schoolRegistration);
                        objContext.SaveChanges();
                        newIdentityValue  = objContext.IPTSE_School_Reg_table.DefaultIfEmpty().Max(r => r == null ? 0 : r.Id);
                        _objLoginTable.Id = newIdentityValue;
                        byte[] encode = new byte[schoolRegistrationModel.password.Length];
                        encode = System.Text.Encoding.UTF8.GetBytes(schoolRegistrationModel.password);
                        _objLoginTable.password   = Convert.ToBase64String(encode);
                        _objLoginTable.email      = schoolRegistrationModel.institution_email;
                        _objLoginTable.Login_type = "Institution";
                        objContext.login_table.Add(_objLoginTable);
                        objContext.SaveChanges();
                        dbcxtransaction.Commit();
                        return(newIdentityValue);
                    }
                    catch (Exception ex)
                    {
                        dbcxtransaction.Rollback();
                        throw ex;
                    }
                }
            }
        }
        public async Task <IHttpActionResult> receptionLogin(login_table verifyReception)
        {
            login_table reception = await db.login_table.FindAsync(verifyReception.login_id);

            if (reception != null)
            {
                if (reception.login_password == verifyReception.login_password)
                {
                    return(Ok("login successfull"));
                }
            }
            return(NotFound());
        }
示例#9
0
 public ActionResult Index()
 {
     if (Session["UserProfile"] != null)
     {
         objUProfile                       = (login_table)Session["UserProfile"];
         objExamCompletion                 = new UserExamCompletion();
         objFinalTest                      = new FinalTestBLL();
         objExamCompletion.CandidateId     = Convert.ToInt32(objUProfile.Id);
         objExamCompletion.IsExamCompleted = true;
         objExamCompletion.CreatedBy       = objUProfile.email;
         objFinalTest.IsExamCompletion(objExamCompletion);
         Session["UserProfile"] = null;
         return(View());
     }
     else
     {
         return(RedirectToAction("Login", "IPTSELogin"));
     }
 }
        public void SaveAnswer(Questions questions, login_table objUserProfile)
        {
            tbl_Txn_Test_Result           objQuest       = new tbl_Txn_Test_Result();
            tbl_Question_Choice           objQuestChoice = new tbl_Question_Choice();
            tbl_Txn_Question_Duration_Map objMap         = new tbl_Txn_Question_Duration_Map();

            using (var objContext = new IPTSE_EXAMEntities())
            {
                using (var dbcxtransaction = objContext.Database.BeginTransaction())
                {
                    try
                    {
                        objQuest.CandidateId      = Convert.ToInt32(objUserProfile.Id);
                        objQuest.CandidateEmailId = objUserProfile.email;
                        objQuest.TestXQId         = questions.Id;
                        objQuest.ChoiceId         = questions.selectedvalue;
                        objQuest.MarkScored       = questions.markScored;
                        var isRight = objContext.tbl_Question_Choice.Where(t => t.Id == questions.selectedvalue).Select(t1 => t1.IsAnswer).ToString();
                        if (isRight == "true")
                        {
                            objQuest.MarkScored = objContext.tbl_Question.Where(t1 => t1.Id == questions.Id).Select(t2 => t2.Points).FirstOrDefault();
                        }
                        objQuest.CreatedBy   = objUserProfile.email;
                        objQuest.CreatedDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        objContext.tbl_Txn_Test_Result.Add(objQuest);
                        objMap.TestXQId       = questions.Id;
                        objMap.AnswerTime_Sec = Convert.ToInt32(60 - Convert.ToInt32(questions.skippedTime.Substring(questions.skippedTime.Length - 2)));
                        //objMap.AnswerTime_Sec = Convert.ToInt32(timeSpend);
                        objMap.CreatedBy   = objUserProfile.email;
                        objMap.CreatedDate = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById("India Standard Time"));
                        objContext.tbl_Txn_Question_Duration_Map.Add(objMap);
                        objContext.SaveChanges();
                        dbcxtransaction.Commit();
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                }
            }
        }
示例#11
0
        private void sendMail(Exception ex)
        {
            string smsg = "";

            if (Session["UserProfile"] != null)
            {
                objUProfile = (login_table)Session["UserProfile"];
                smsg       += "User Name:-" + objUProfile.email + " <br/><br/> ";
            }
            smsg += ex.Message + " <br/><br/> ";
            smsg += ex.InnerException != null?ex.InnerException.ToString() : "";

            smsg += "<br/><br/>" + ex.StackTrace.ToString();
            try
            {
                System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                message.To.Add(new MailAddress("*****@*****.**"));
                message.To.Add(new MailAddress("*****@*****.**"));
                message.From       = new MailAddress("*****@*****.**");
                message.Subject    = "IPTSE Examination Error.";
                message.Body       = smsg;
                message.IsBodyHtml = true;
                SmtpClient client = new SmtpClient();
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Port           = 80;
                client.Host           = "smtpout.asia.secureserver.net";
                NetworkCredential nc = new NetworkCredential("*****@*****.**", "Iptse@2018");
                client.EnableSsl             = false;
                client.UseDefaultCredentials = true;
                client.Credentials           = nc;
                client.Send(message);
            }
            catch (Exception ex1)
            {
                ViewBag.ErrorMessage = "Unable to send mail. Please contact support team for regisration confirmation";
            }
        }
        public bool IsExamGiven(login_table objUProfile)
        {
            tbl_txn_Test_Completion objTestCompletion = new tbl_txn_Test_Completion();

            using (var objContext = new IPTSE_EXAMEntities())
            {
                using (var dbcxtransaction = objContext.Database.BeginTransaction())
                {
                    try
                    {
                        var isCompletion = objContext.tbl_txn_Test_Completion.Where(t => t.CreatedBy == objUProfile.email && t.CandidateId == objUProfile.Id).Select(t1 => t1).FirstOrDefault();
                        if (isCompletion != null)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    }
                    catch { return(false); }
                }
            }
        }
 public ActionResult Login(login_table login_table)
 {
     try
     {
         if (ModelState.IsValid)
         {
             using (var db = new LoginDataModel())
             {
                 Session["TestId"] = "";
                 byte[] encode = new byte[login_table.password.Length];
                 encode = System.Text.Encoding.UTF8.GetBytes(login_table.password);
                 login_table.password = Convert.ToBase64String(encode);
                 bool allDigits = login_table.email.All(char.IsDigit);
                 if (allDigits)
                 {
                     var loginId = Decimal.Parse(login_table.email);
                     var obj     = db.login_table.Where(a => a.Id.Equals(loginId) && a.password.Equals(login_table.password)).FirstOrDefault();
                     if (obj != null)
                     {
                         FinalTestBLL objFinalTest = new FinalTestBLL();
                         bool         isExamGiven  = objFinalTest.IsExamGiven(obj);
                         if (isExamGiven)
                         {
                             ViewBag.ErrorMessage = "You have already completed your exam!";
                             return(View());
                         }
                         else
                         {
                             Session["id"]          = obj.Id.ToString();
                             Session["UserProfile"] = obj;
                             ViewBag.UID            = HttpUtility.UrlEncode(Encrypt(obj.Id.ToString()));
                             Session["Type"]        = obj.Login_type;
                             payment_details payment_Details = new payment_details();
                             payment_Details.Id = Decimal.Parse(Session["id"].ToString());
                             var objPayment = pDB.payment_details.Where(a => a.Id.Equals(payment_Details.Id)).FirstOrDefault();
                             if (objPayment == null)
                             {
                                 ViewBag.PaymentMessage = "Payment";
                                 return(View());
                             }
                             else
                             {
                                 var insType = rDB.IPTSE_Reg_table.Where(t => t.Id.Equals(obj.Id)).Select(t1 => t1.InstitutionType).FirstOrDefault();
                                 if (insType == "School")
                                 {
                                     Session["TestId"] = 2;
                                     return(RedirectToAction("Index", "School"));
                                 }
                                 else if (insType == "College")
                                 {
                                     Session["TestId"] = 2; return(RedirectToAction("Index", "College"));
                                 }
                                 else
                                 {
                                     Session["TestId"] = 1; return(RedirectToAction("Index", "Mock"));
                                 }
                             }
                         }
                     }
                     else
                     {
                         if (loginId == Decimal.Parse("91620195"))
                         {
                             //if (login_table.password == "YWJjQDEyMw==") //"SVBUU0VfQURNSU5fTE9HSU4 =")
                             //{
                             Session["admin_login"] = "******";
                             return(RedirectToAction("Index", "Admin"));
                             //}
                         }
                         ViewBag.ErrorMessage = "Invalid Credentials....";
                         return(View());
                     }
                 }
                 else
                 {
                     var obj1 = db.login_table.Where(a => a.email.Equals(login_table.email) && a.password.Equals(login_table.password)).FirstOrDefault();
                     if (obj1 != null)
                     {
                         FinalTestBLL objFinalTest = new FinalTestBLL();
                         bool         isExamGiven  = objFinalTest.IsExamGiven(obj1);
                         if (isExamGiven)
                         {
                             ViewBag.ErrorMessage = "You have already completed your exam!";
                             return(View());
                         }
                         else
                         {
                             Session["id"]          = obj1.Id.ToString();
                             ViewBag.UID            = HttpUtility.UrlEncode(Encrypt(obj1.Id.ToString()));
                             Session["UserProfile"] = obj1;
                             Session["Type"]        = obj1.Login_type;
                             obj1.LastLoginDateTime = DateTime.Now;
                             payment_details payment_Details = new payment_details();
                             payment_Details.Id = Decimal.Parse(Session["id"].ToString());
                             var objPayment = pDB.payment_details.Where(a => a.Id.Equals(payment_Details.Id)).FirstOrDefault();
                             if (objPayment == null)
                             {
                                 ViewBag.PaymentMessage = "Payment";
                                 return(View());
                             }
                             else
                             {
                                 var insType = rDB.IPTSE_Reg_table.Where(t => t.Id.Equals(obj1.Id)).Select(t1 => t1.InstitutionType).FirstOrDefault();
                                 if (insType == "School")
                                 {
                                     Session["TestId"] = 2; return(RedirectToAction("Index", "School"));
                                 }
                                 else if (insType == "College")
                                 {
                                     Session["TestId"] = 2; return(RedirectToAction("Index", "College"));
                                 }
                                 else
                                 {
                                     Session["TestId"] = 1; return(RedirectToAction("Index", "Mock"));
                                 }
                             }
                         }
                     }
                     else
                     {
                         if (login_table.Id == Decimal.Parse("91620195"))
                         {
                             if (login_table.password == "SVBUU0VfQURNSU5fTE9HSU4=")
                             {
                                 Session["admin_login"] = "******";
                                 return(RedirectToAction("Index", "Admin"));
                             }
                         }
                         ViewBag.ErrorMessage = "Invalid Credentials....";
                         return(View());
                     }
                 }
             }
         }
         return(View(login_table));
     }
     catch (Exception ex)
     {
         Session["ErrorMessage"] = ex;
         return(RedirectToAction("Index", "Error"));
     }
 }
示例#14
0
 public ActionResult Login(login_table login_table)
 {
     if (ModelState.IsValid)
     {
         using (db)
         {
             byte[] encode = new byte[login_table.password.Length];
             encode = System.Text.Encoding.UTF8.GetBytes(login_table.password);
             login_table.password = Convert.ToBase64String(encode);
             bool allDigits = login_table.email.All(char.IsDigit);
             if (allDigits)
             {
                 var loginId = Int32.Parse(login_table.email);
                 var obj     = db.login_table.Where(a => a.Id.Equals(loginId) && a.password.Equals(login_table.password)).FirstOrDefault();
                 if (obj != null)
                 {
                     Session["id"]   = obj.Id.ToString();
                     Session["Type"] = obj.Login_type;
                     //obj.LastLoginDateTime = DateTime.Now;
                     //db.login_table.Attach(obj);
                     //db.Entry(login_table).State = EntityState.Modified;
                     //db.SaveChanges();
                     return(RedirectToAction("Index", "Dashboard"));
                 }
                 else
                 {
                     if (loginId == Decimal.Parse("91620195"))
                     {
                         if (login_table.password == "YWJjQDEyMw==") //"SVBUU0VfQURNSU5fTE9HSU4 =")
                         {
                             Session["admin_login"] = "******";
                             //obj.LastLoginDateTime = DateTime.Now;
                             //db.login_table.Attach(obj);
                             //db.Entry(login_table).State = EntityState.Modified;
                             //db.SaveChanges();
                             return(RedirectToAction("Index", "Admin"));
                         }
                     }
                     ViewBag.ErrorMessage = "Invalid Credentials....";
                     return(View());
                 }
             }
             else
             {
                 var obj1 = db.login_table.Where(a => a.email.Equals(login_table.email) && a.password.Equals(login_table.password)).FirstOrDefault();
                 if (obj1 != null)
                 {
                     Session["id"]          = obj1.Id.ToString();
                     Session["Type"]        = obj1.Login_type;
                     obj1.LastLoginDateTime = DateTime.Now;
                     //db.login_table.Add(obj1);
                     //// db.Entry(login_table).State = EntityState.Modified;
                     ////db.Entry(login_table).Property(x => x.LastLoginDateTime).IsModified = true;
                     //db.Entry(obj1).State = System.Data.Entity.EntityState.Modified;
                     //db.SaveChanges();
                     return(RedirectToAction("Index", "Dashboard"));
                 }
                 else
                 {
                     if (login_table.Id == Decimal.Parse("91620195"))
                     {
                         if (login_table.password == "SVBUU0VfQURNSU5fTE9HSU4=")
                         {
                             Session["admin_login"] = "******";
                             //obj1.LastLoginDateTime = DateTime.Now;
                             //db.login_table.Attach(obj1);
                             //db.Entry(login_table).State = EntityState.Modified;
                             //db.SaveChanges();
                             return(RedirectToAction("Index", "Admin"));
                         }
                     }
                     ViewBag.ErrorMessage = "Invalid Credentials....";
                     return(View());
                 }
             }
         }
     }
     return(View(login_table));
 }
示例#15
0
        public ActionResult Registration([Bind(Include = "Id,first_name,mid_name,last_name,dob,gender,email,fathername,mothername,country,addr1,addr2,city,state,zipcode,contact,password,confirmpassword,schoolname,InstitutionType,standard,volunteername")] IPTSE_Reg_table_New iPTSE_Reg_table)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    string clearText;

                    if (iPTSE_Reg_table.password != iPTSE_Reg_table.confirmpassword)
                    {
                        return(Content("<script language='javascript' type='text/javascript'>alert('Password and Confirm Password should be same!');</script>"));
                    }
                    else
                    {
                        IPTSE_Reg_table iPTSE_Reg_table_New = new IPTSE_Reg_table();
                        iPTSE_Reg_table_New.Id              = iPTSE_Reg_table.Id;
                        iPTSE_Reg_table_New.first_name      = iPTSE_Reg_table.first_name;
                        iPTSE_Reg_table_New.mid_name        = iPTSE_Reg_table.mid_name;
                        iPTSE_Reg_table_New.last_name       = iPTSE_Reg_table.last_name;
                        iPTSE_Reg_table_New.dob             = iPTSE_Reg_table.dob;
                        iPTSE_Reg_table_New.gender          = iPTSE_Reg_table.gender;
                        iPTSE_Reg_table_New.email           = iPTSE_Reg_table.email;
                        iPTSE_Reg_table_New.fathername      = iPTSE_Reg_table.fathername;
                        iPTSE_Reg_table_New.mothername      = iPTSE_Reg_table.mothername;
                        iPTSE_Reg_table_New.country         = iPTSE_Reg_table.country;
                        iPTSE_Reg_table_New.addr1           = iPTSE_Reg_table.addr1;
                        iPTSE_Reg_table_New.addr2           = iPTSE_Reg_table.addr2;
                        iPTSE_Reg_table_New.city            = iPTSE_Reg_table.city;
                        iPTSE_Reg_table_New.state           = iPTSE_Reg_table.state;
                        iPTSE_Reg_table_New.zipcode         = iPTSE_Reg_table.zipcode;
                        iPTSE_Reg_table_New.contact         = iPTSE_Reg_table.contact;
                        iPTSE_Reg_table_New.schoolname      = iPTSE_Reg_table.schoolname;
                        iPTSE_Reg_table_New.InstitutionType = iPTSE_Reg_table.InstitutionType;
                        iPTSE_Reg_table_New.standard        = iPTSE_Reg_table.standard;
                        iPTSE_Reg_table_New.volunteername   = iPTSE_Reg_table.volunteername;
                        db.IPTSE_Reg_table.Add(iPTSE_Reg_table_New);
                        db.SaveChanges();
                        var         lstId       = db.IPTSE_Reg_table.OrderByDescending(t => t.Id).Select(t1 => t1.Id).FirstOrDefault();
                        login_table login_table = new login_table();
                        login_table.Id       = lstId;
                        login_table.email    = iPTSE_Reg_table.email;
                        login_table.password = iPTSE_Reg_table.password;
                        Createpassword(login_table);
                        //Session["id"] = iPTSE_Reg_table.Id;

                        string EncryptionKey = "MAKV2SPBNI99212";
                        byte[] clearBytes    = System.Text.Encoding.Unicode.GetBytes(iPTSE_Reg_table.Id.ToString());
                        using (Aes encryptor = Aes.Create())
                        {
                            Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
                            encryptor.Key = pdb.GetBytes(32);
                            encryptor.IV  = pdb.GetBytes(16);
                            using (MemoryStream ms = new MemoryStream())
                            {
                                using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                                {
                                    cs.Write(clearBytes, 0, clearBytes.Length);
                                    cs.Close();
                                }
                                clearText = Convert.ToBase64String(ms.ToArray());
                            }
                        }

                        string siteurl = "http://portal.iptse.com/IPTSELogin/Createpassword";
                        string smsg    = "Dear User,<br/> Your Registration has been sucessfully done.";
                        smsg += "<br/>Please login with your email-id.<br/> Thank you <br/> IPTSE Admin.";
                        try
                        {
                            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                            message.To.Add(new MailAddress(iPTSE_Reg_table.email));
                            message.From       = new MailAddress("*****@*****.**");
                            message.Subject    = "IPTSE Registration Confirmation Mail.";
                            message.Body       = smsg;
                            message.IsBodyHtml = true;
                            SmtpClient client = new SmtpClient();
                            client.DeliveryMethod = SmtpDeliveryMethod.Network;
                            client.Port           = 80;
                            client.Host           = "smtpout.asia.secureserver.net";
                            NetworkCredential nc = new NetworkCredential("*****@*****.**", "Iptse@2018");
                            client.EnableSsl             = false;
                            client.UseDefaultCredentials = true;
                            client.Credentials           = nc;
                            client.Send(message);
                        }
                        catch (Exception ex)
                        {
                            ViewBag.ErrorMessage = "Unable to send mail...";
                            return(View());
                        }
                        ViewData["success_msg"] = "Congratulation! you have Registered Successfully.";
                        return(View("Successfull"));
                    }
                }
                catch (System.Data.Entity.Validation.DbEntityValidationException dbEx)
                {
                    Exception raise = dbEx;
                    foreach (var validationErrors in dbEx.EntityValidationErrors)
                    {
                        foreach (var validationError in validationErrors.ValidationErrors)
                        {
                            string message = string.Format("{0}:{1}",
                                                           validationErrors.Entry.Entity.ToString(),
                                                           validationError.ErrorMessage);
                            // raise a new exception nesting
                            // the current instance as InnerException
                            raise = new InvalidOperationException(message, raise);
                        }
                    }
                    throw raise;
                }
                catch (Exception ex1)
                {
                    ViewBag.ErrorMessage = "Already Registered. if you are unable to login Please go through Forgot Password";
                    return(View());
                }
            }
            return(View(iPTSE_Reg_table));
        }
示例#16
0
        public ActionResult ForgetPassword(IPTSE_Reg_table iPTSE_Reg_table)
        {
            //var obj = db.IPTSE_Reg_table.Where(a => a.email.Equals(iPTSE_Reg_table.email)).FirstOrDefault();
            var usermail = iPTSE_Reg_table.email;
            var obj      = db1.login_table.Where(a => a.email.Equals(usermail)).FirstOrDefault();

            if (obj != null)
            {
                login_table login_Table = new login_table();
                var         obj1        = db1.login_table.Where(a => a.Id.Equals(obj.Id)).FirstOrDefault();
                if (obj1 != null)
                {
                    System.Text.UTF8Encoding encoder    = new System.Text.UTF8Encoding();
                    System.Text.Decoder      strDecoder = encoder.GetDecoder();
                    byte[] to_DecodeByte = Convert.FromBase64String(obj1.password);
                    int    charCount     = strDecoder.GetCharCount(to_DecodeByte, 0, to_DecodeByte.Length);
                    char[] decoded_char  = new char[charCount];
                    strDecoder.GetChars(to_DecodeByte, 0, to_DecodeByte.Length, decoded_char, 0);
                    string depass = new string(decoded_char);

                    string smsg = "Your User Id : " + obj.Id;
                    smsg += "\n Your Password : "******"*****@*****.**");
                        message.Subject = "IPTSE Login Details";
                        message.Body    = smsg;
                        //message.IsBodyHtml = true;
                        SmtpClient client = new SmtpClient();
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.Port           = 80;
                        client.Host           = "smtpout.asia.secureserver.net";
                        NetworkCredential nc = new NetworkCredential("*****@*****.**", "Iptse@2018");
                        client.EnableSsl             = false;
                        client.UseDefaultCredentials = true;
                        client.Credentials           = nc;
                        client.Send(message);
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorMessage = "Unable to send mail..." + ex.Message;
                        return(View());
                    }
                    ViewData["success_msg"] = "Your Id and password has been sent to your registered mail id!";
                    return(View("Successfull"));
                }
                else
                {
                    string clearText;
                    string EncryptionKey = "MAKV2SPBNI99212";
                    byte[] clearBytes    = System.Text.Encoding.Unicode.GetBytes(obj.Id.ToString());
                    using (Aes encryptor = Aes.Create())
                    {
                        Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
                        encryptor.Key = pdb.GetBytes(32);
                        encryptor.IV  = pdb.GetBytes(16);
                        using (MemoryStream ms = new MemoryStream())
                        {
                            using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
                            {
                                cs.Write(clearBytes, 0, clearBytes.Length);
                                cs.Close();
                            }
                            clearText = Convert.ToBase64String(ms.ToArray());
                        }
                    }

                    string siteurl = "http://portal.iptse.com/IPTSELogin/Login";
                    string smsg    = "New Registration on our website.";
                    smsg += "Your account is activated now, please login with your email-id.";
                    try
                    {
                        System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                        message.To.Add(new MailAddress(iPTSE_Reg_table.email));
                        message.From       = new MailAddress("*****@*****.**");
                        message.Subject    = "Verification Mail";
                        message.Body       = smsg;
                        message.IsBodyHtml = true;
                        SmtpClient client = new SmtpClient();
                        client.DeliveryMethod = SmtpDeliveryMethod.Network;
                        client.Port           = 80;
                        client.Host           = "smtpout.asia.secureserver.net";
                        NetworkCredential nc = new NetworkCredential("*****@*****.**", "Iptse@2018");
                        client.EnableSsl             = false;
                        client.UseDefaultCredentials = true;
                        client.Credentials           = nc;
                        client.Send(message);
                    }
                    catch (Exception ex)
                    {
                        ViewBag.ErrorMessage = "Unable to send mail...";
                        return(View());
                    }

                    ViewData["success_msg"] = "You did not yet create password!";
                    //ViewData["success_msg1"] = "Verification Mail has been sent to your registered Email-Id";
                    return(View("Successfull"));
                }
            }
            else
            {
                ViewBag.ErrorMessage = "Email id is not Registered.";
                return(View());
            }
        }
示例#17
0
        public ActionResult NextQuestion(Questions aaa)
        {
            try
            {
                if (aaa.IsskipQuestions == true && aaa.prevQuestions == false)
                {
                    return(SkipQuestion(aaa.Id, aaa.TotalTime, aaa.skippedTime));
                }
                else if (aaa.IsskipQuestions == false && aaa.prevQuestions == true)
                {
                    return(PrevQuestion(aaa.Id, aaa.TotalTime, aaa.skippedTime));
                }
                else
                {
                    MockTestBLL objMock = new MockTestBLL();
                    if (Session["Result"] != null)
                    {
                        lstQuestionsForResult = (List <Questions>)Session["Result"];
                    }
                    Boolean isAnswer = objMock.isAnswer(aaa.selectedvalue);
                    if (isAnswer == true)
                    {
                        aaa.markScored = 1;
                    }
                    else
                    {
                        aaa.markScored = 0;
                    }
                    string aaa1 = ViewBag.Timedur;
                    ViewBag.questionNo = Session["questNo"];
                    lstQuestions       = (List <Questions>)Session["Questions"];
                    Session["Next"]    = "true";
                    var itemToRemove = lstQuestions.SingleOrDefault(r => r.Id == aaa.Id && r.skipQuestions == false);
                    if (itemToRemove != null)
                    {
                        itemToRemove.skippedTime  = Convert.ToString(60 - Convert.ToInt32(aaa.skippedTime.Substring(aaa.skippedTime.Length - 2))) + " sec";
                        itemToRemove.SelectedText = objMock.selectedAnswer(aaa.selectedvalue);
                        Boolean isAnswer1 = objMock.isAnswer(aaa.selectedvalue);
                        if (isAnswer1 == true)
                        {
                            itemToRemove.markScored = 1;
                        }
                        else
                        {
                            itemToRemove.markScored = 0;
                        }
                        lstQuestionsForResult.Add(itemToRemove);
                    }
                    Session["Result"] = lstQuestionsForResult;
                    lstQuestions.RemoveAll(t => t.Id == aaa.Id && t.skipQuestions == false);
                    Session["Questions"] = lstQuestions.OrderBy(t2 => t2.QuestNo).ToList();

                    if (lstQuestions.Count <= 48 && lstQuestions.Count > 0 && ViewBag.questionNo <= 48)
                    {
                        lstQuestions = lstQuestions.Where(t => t.skipQuestions == false).Select(t1 => t1).ToList();
                        if (lstQuestions.Count == 0)
                        {
                            var lstQuestionsSkipped = lstQuestions.Where(t => t.skipQuestions == true).Select(t1 => t1).ToList();
                            if (lstQuestionsSkipped.Count > 0)
                            {
                                Session["isBack"] = true;
                                foreach (var item in lstQuestionsSkipped)
                                {
                                    lstQuestionsForResult.Add(item);
                                    Session["Result"] = lstQuestionsForResult;
                                    var spendTime1 = item.TotalTime.Substring(item.TotalTime.Length - 5);
                                    ViewBag.TotalTime = spendTime1;
                                    var spendTimeArr1 = spendTime1.Split(':');
                                    int spendSecond1  = 60 - Convert.ToInt32(spendTimeArr1[1]);
                                    item.SpendTime = spendSecond1.ToString();
                                    objUProfile    = (login_table)Session["UserProfile"];
                                    objMock.SaveAnswer(item, objUProfile);
                                }
                            }
                            else
                            {
                                Session["isBack"] = false;
                            }
                            ViewData["success_msg"] = "Congratulation! you have successfully completed your Mock Test.";
                            return(RedirectToAction("Index", "Result"));
                            //return RedirectToAction("CollegeTest", "College");
                        }
                        else
                        {
                            //ViewBag.isSkip = true;
                            var lstQuestionsNew = lstQuestions.Where(t => t.skipQuestions == true).Select(t1 => t1).ToList();
                            if (lstQuestionsNew.Count > 0)
                            {
                                Session["isBack"] = true;
                            }
                            else
                            {
                                Session["isBack"] = false;
                            }
                            objQusetion = new Questions();
                            objQusetion = lstQuestions.OrderBy(t2 => t2.QuestNo).FirstOrDefault();
                            var spendTime = aaa.TotalTime.Substring(aaa.TotalTime.Length - 15);
                            objQusetion.TotalTime     = spendTime;
                            objQusetion.remainingTime = 60;
                            Session["qData"]          = objQusetion;
                            Session["questNo"]        = objQusetion.QuestNo;
                            ViewBag.remainingTime     = 60;
                            Session["remainTime"]     = 60;
                            int spendSecond = 60 - Convert.ToInt32(aaa.TotalTime.Substring(31, 2));
                            aaa.SpendTime = spendSecond.ToString();
                            objUProfile   = (login_table)Session["UserProfile"];
                            objMock.SaveAnswer(aaa, objUProfile);
                            return(RedirectToAction("CollegeTest", "College"));
                        }
                    }
                    else
                    {
                        ViewData["success_msg"] = "Congratulation! you have successfully completed your Test.";
                        return(RedirectToAction("Index", "Result"));
                        //return RedirectToAction("CollegeTest", "College");
                    }
                }
            }
            catch (Exception ex)
            {
                Session["ErrorMessage"] = ex;
                return(RedirectToAction("Index", "Error"));
            }
        }
        public ActionResult NextQuestionTimeOut(int QuestId, string TotalTime, string skippedTime)
        {
            try
            {
                MockTestBLL objMock = new MockTestBLL();
                // lstQuestionsForResult = new List<Questions>();
                if (Session["Result"] != null)
                {
                    lstQuestionsForResult = (List <Questions>)Session["Result"];
                }
                //Boolean isAnswer = objMock.isAnswer(aaa.selectedvalue);
                //if (isAnswer == true)
                //{ aaa.markScored = 1; }
                //else
                //{ aaa.markScored = 0; }

                ViewBag.questionNo = Session["questNo"];
                lstQuestions       = (List <Questions>)Session["Questions"];
                if (lstQuestions != null)
                {
                    Session["Next"] = "true";
                    var itemToRemove = lstQuestions.SingleOrDefault(r => r.Id == Convert.ToInt32(QuestId) && r.skipQuestions == false);
                    if (itemToRemove != null)
                    {
                        itemToRemove.skippedTime  = Convert.ToString("0"); // Convert.ToString(60 - Convert.ToInt32(questionsTimeOut.skippedTime.Substring(questionsTimeOut.skippedTime.Length - 2)));
                        itemToRemove.SelectedText = "";                    //objMock.selectedAnswer(questionsTimeOut.selectedvalue);
                                                                           //Boolean isAnswer1 = objMock.isAnswer(questionsTimeOut.selectedvalue);
                        itemToRemove.markScored = 0;
                        lstQuestionsForResult.Add(itemToRemove);
                    }
                    Session["Result"] = lstQuestionsForResult;
                    lstQuestions.RemoveAll(t => t.Id == Convert.ToInt32(QuestId) && t.skipQuestions == false);
                    Session["Questions"] = lstQuestions.OrderBy(t2 => t2.QuestNo).ToList();
                    if (lstQuestions.Count <= 36 && lstQuestions.Count > 0 && ViewBag.questionNo <= 36)
                    {
                        lstQuestions = lstQuestions.Where(t => t.skipQuestions == false).Select(t1 => t1).ToList();
                        if (lstQuestions.Count == 0)
                        {
                            var lstQuestionsSkipped = lstQuestions.Where(t => t.skipQuestions == true).Select(t1 => t1).ToList();
                            if (lstQuestionsSkipped.Count > 0)
                            {
                                Session["isBack"] = true;
                                foreach (var item in lstQuestionsSkipped)
                                {
                                    lstQuestionsForResult.Add(item);
                                    Session["Result"] = lstQuestionsForResult;
                                    var spendTime1    = item.TotalTime.Substring(item.TotalTime.Length - 4);
                                    var spendTimeArr1 = spendTime1.Split(':');
                                    int spendSecond1  = 60 - Convert.ToInt32(spendTimeArr1[1]);
                                    item.SpendTime = spendSecond1.ToString();
                                    objUProfile    = (login_table)Session["UserProfile"];
                                    objMock.SaveAnswer(item, objUProfile);
                                }
                            }
                            else
                            {
                                Session["isBack"] = false;
                            }

                            ViewData["success_msg"] = "Congratulation! you have successfully completed your School Test.";
                            return(RedirectToAction("Index", "Result"));
                        }
                        else
                        {
                            var lstQuestNew = lstQuestions.Where(t => t.skipQuestions == true).Select(t1 => t1).ToList();
                            if (lstQuestNew.Count > 0)
                            {
                                Session["isBack"] = true;
                            }
                            else
                            {
                                Session["isBack"] = false;
                            }
                            objQusetion = new Questions();
                            objQusetion = lstQuestions.OrderBy(t2 => t2.QuestNo).FirstOrDefault();
                            objQusetion.remainingTime = 60;
                            var spendTime = TotalTime.Substring(TotalTime.Length - 15);
                            objQusetion.TotalTime     = spendTime;
                            objQusetion.remainingTime = 60;
                            Session["qData"]          = objQusetion;
                            Session["questNo"]        = objQusetion.QuestNo;
                            ViewBag.remainingTime     = 60;
                            Session["remainTime"]     = 60;
                            // int spendSecond = 60 - Convert.ToInt32(aaa.TotalTime.Substring(31, 2));
                            //  aaa.SpendTime = spendSecond.ToString();
                            objUProfile = (login_table)Session["UserProfile"];
                            objMock.SaveAnswerTimeOut(objQusetion, objUProfile);
                            return(RedirectToAction("SchoolTest", "School"));
                        }
                    }
                    else
                    {
                        ViewData["success_msg"] = "Congratulation! you have successfully completed your School Test.";
                        return(RedirectToAction("Index", "Result"));
                    }
                }
                return(RedirectToAction("SchoolTest", "School"));
            }
            catch (Exception ex)
            {
                Session["ErrorMessage"] = ex;
                return(RedirectToAction("Index", "Error"));
            }
        }