public ActionResult Details(decimal id) { if (Session["admin_login"] == null) { return(RedirectToAction("Login", "IPTSELogin")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } else if (id > 0) { Session["DetailId"] = id; } IPTSE_Reg_table iPTSE_Reg_table = db.IPTSE_Reg_table.Find(id); payment_details paymentDetail = new payment_details(); ViewData["RegInfo"] = iPTSE_Reg_table; ViewData["PaymentDetail"] = paymentDetail; if (iPTSE_Reg_table == null) { return(HttpNotFound()); } return(View()); }
public ActionResult UserProfile() { if (Session["id"] == null) { return(RedirectToAction("Login", "IPTSELogin")); } if (Session["Type"] != null && Session["Type"].ToString() == "Institution") { using (var client = new HttpClient()) { client.BaseAddress = new Uri("http://portal.iptse.com/"); //localhost:63138/ //client.BaseAddress = new Uri("http://localhost:63138/"); var postTask = client.GetAsync("api/SchoolRegistrationAPI/" + Session["id"].ToString()); postTask.Wait(); var result = postTask.Result; //TODO - fix this if condition if (result.IsSuccessStatusCode) { //ViewData["success_msg"] = "Congratulation! you have Registered Successfully."; return(View(result)); } else { return(View()); } } //BLL.Models.SchoolRegistrationModel iPTSE_Reg_Table = new BLL.Models.SchoolRegistrationModel(); //iPTSE_Reg_Table.Id = Int32.Parse(Session["id"].ToString()); //var obj = reg.IPTSE_Reg_table.Where(a => a.Id.Equals(iPTSE_Reg_Table.Id)).FirstOrDefault(); //obj.contact = obj.contact.ToString(); //return View(obj); } else { IPTSE_Reg_table iPTSE_Reg_Table = new IPTSE_Reg_table(); iPTSE_Reg_Table.Id = Int32.Parse(Session["id"].ToString()); var obj = reg.IPTSE_Reg_table.Where(a => a.Id.Equals(iPTSE_Reg_Table.Id)).FirstOrDefault(); obj.contact = obj.contact.ToString(); return(View(obj)); } }
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)); }
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()); } }
public ActionResult BulkRegistration(HttpPostedFileBase postedFile) { HttpPostedFileBase file = Request.Files["postedFile"]; List <IPTSE_Reg_table> student_Details = new List <IPTSE_Reg_table>(); string filePath = string.Empty; if (postedFile != null) { try { string path = Server.MapPath("~/App_Data/Uploads/"); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } filePath = path + Path.GetFileName(postedFile.FileName); string extension = Path.GetExtension(postedFile.FileName); if (extension.Equals(".csv", StringComparison.InvariantCultureIgnoreCase)) { postedFile.SaveAs(filePath); //Read the contents of CSV file. string csvData = System.IO.File.ReadAllText(filePath); //Execute a loop over the rows. char[] trimChars = { '\r', '\n' }; csvData = csvData.TrimEnd(trimChars); string[] rows = csvData.Split('\n'); for (int i = 1; i < rows.Length; i++) { var rowparts = rows[i].Split(','); IPTSE_Reg_table datarow = new IPTSE_Reg_table(); datarow.first_name = rowparts[0]; datarow.mid_name = rowparts[1]; datarow.last_name = rowparts[2]; datarow.dob = Convert.ToDateTime(rowparts[3]); datarow.gender = rowparts[4]; datarow.email = rowparts[5]; datarow.fathername = rowparts[6]; datarow.mothername = rowparts[7]; datarow.country = rowparts[8]; datarow.addr1 = rowparts[9]; datarow.addr2 = rowparts[10]; datarow.city = rowparts[11]; datarow.state = rowparts[12]; datarow.zipcode = rowparts[13]; datarow.contact = rowparts[14]; datarow.schoolname = rowparts[15]; datarow.standard = rowparts[16]; datarow.volunteername = rowparts[17]; datarow.InstitutionType = string.Empty; datarow.School_ID = Session["id"] != null ? Session["id"].ToString(): null; student_Details.Add(datarow); ViewBag.Message = "File uploaded successfully"; } } else { ViewBag.Message = "Please upload a csv file only"; } } catch (Exception ex) { ViewBag.Message = ex.Message; } } else { ViewBag.Message = "Please verify, if you have selected a valid file"; } ViewData["StudentDetails"] = student_Details; Session["StudentDetail"] = student_Details; return(View("BulkReg")); }