public ActionResult Create([Bind(Include = "Registration_Token_ID,Registration_Token1,New_Email,Access_Level_ID,Employee_ID")] registration_token registration_token) { RNGCryptoServiceProvider rngCryptoServiceProvider = new RNGCryptoServiceProvider(); byte[] randomBytes = new byte[6]; rngCryptoServiceProvider.GetBytes(randomBytes); if (ModelState.IsValid) { registration_token.Registration_Token1 = Convert.ToBase64String(randomBytes); registration_token.Employee_ID = null; db.registration_token.Add(registration_token); db.SaveChanges(); //[email protected] upg$H101 //This is for an emal service Remeber this ! MailMessage mail = new MailMessage("*****@*****.**", registration_token.New_Email); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "k1Yvi2&5"); client.Host = "nl1-wss2.a2hosting.com"; mail.Subject = "Registration Token"; mail.Body = "Hi " + registration_token.New_Email + "\n\nHere is you registration token: " + Convert.ToBase64String(randomBytes) + "\nIf you are a manager you can ignore this token as it is just for security, go onto https://repsonthemove.com/Account/Register and register as a normal. " + "\n\nRegards" + "\nReps On The Move Team"; client.Send(mail); return(RedirectToAction("Index")); } ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); return(View(registration_token)); }
public ActionResult DeleteConfirmed(int id) { registration_token registration_token = db.registration_token.Find(id); db.registration_token.Remove(registration_token); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Registration_Token_ID,Registration_Token1,New_Email,Access_Level_ID,Employee_ID")] registration_token registration_token) { if (ModelState.IsValid) { db.Entry(registration_token).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); return(View(registration_token)); }
// GET: registration_token/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } registration_token registration_token = db.registration_token.Find(id); if (registration_token == null) { return(HttpNotFound()); } return(View(registration_token)); }
// GET: registration_token/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } registration_token registration_token = db.registration_token.Find(id); if (registration_token == null) { return(HttpNotFound()); } ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); return(View(registration_token)); }
public ActionResult Create([Bind(Include = "Registration_Token_ID,Registration_Token1,New_Email,Access_Level_ID,Employee_ID")] registration_token registration_token) { //New Token RNGCryptoServiceProvider rngCryptoServiceProvider = new RNGCryptoServiceProvider(); byte[] randomBytes = new byte[6]; rngCryptoServiceProvider.GetBytes(randomBytes); bool val = Validate(registration_token.New_Email); if (ModelState.IsValid && val == false) { registration_token.Registration_Token1 = Convert.ToBase64String(randomBytes); registration_token.Employee_ID = null; db.registration_token.Add(registration_token); db.SaveChanges(); //[email protected] upg$H101 //This is for an emal service Remeber this ! MailMessage mail = new MailMessage("*****@*****.**", registration_token.New_Email); SmtpClient client = new SmtpClient(); client.Port = 25; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "k1Yvi2&5"); client.Host = "nl1-wss2.a2hosting.com"; mail.Subject = "Registration Token"; mail.Body = "Hi there! \n\n You have registered with email address: " + registration_token.New_Email + "\n\nHere is you registration token: " + Convert.ToBase64String(randomBytes) + "\n\nRegards" + "\nReps On The Move Team"; client.Send(mail); return(RedirectToAction("Index")); } else if (val == true) { ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); ViewBag.StatusMessage = "There is already an: " + registration_token.New_Email + " email address registered for a access token."; return(View()); } ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); return(View(registration_token)); }
public ActionResult DeleteConfirmed(int id, audit_trail audit) { registration_token registration_token = db.registration_token.Find(id); var userId = System.Web.HttpContext.Current.Session["UserID"] as String; int IntID = Convert.ToInt32(userId); audit.Employee_ID = IntID; audit.Trail_DateTime = DateTime.Now.Date; audit.Deleted_Record = "Registration Token ID: " + registration_token.Registration_Token_ID.ToString() + " Email Address: " + registration_token.New_Email + " Access Level ID: " + registration_token.Access_Level_ID; audit.Trail_Description = "Deleted a Registration Token."; db.audit_trail.Add(audit); db.registration_token.Remove(registration_token); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Registration_Token_ID,Registration_Token1,New_Email,Access_Level_ID,Employee_ID")] registration_token registration_token) { //Validation for duplicate emails bool val = db.registration_token.Any(s => s.New_Email == registration_token.New_Email && s.Registration_Token_ID != registration_token.Registration_Token_ID); if (ModelState.IsValid && val == false) { db.Entry(registration_token).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } else if (val == true) { ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); ViewBag.StatusMessage = "There is already an: " + registration_token.New_Email + " email address registered for a access token."; return(View()); } ViewBag.Access_Level_ID = new SelectList(db.access_level, "Access_Level_ID", "Access_Level_Name", registration_token.Access_Level_ID); ViewBag.Employee_ID = new SelectList(db.employees, "Employee_ID", "Employee_Name", registration_token.Employee_ID); return(View(registration_token)); }