public JsonResult UpdateToken(long UserId, string SenderId) { var User = db.tblAppLogins.Where(x => x.Id == UserId).Select(y => y).SingleOrDefault(); User.SenderId = SenderId; db.Entry(User).State = EntityState.Modified; db.SaveChanges(); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); }
public ActionResult Edit([Bind(Include = "VersionId,BuidDate,Version,UpdateMessage,Notes")] tblAppVersion tblAppVersion) { if (ModelState.IsValid) { db.Entry(tblAppVersion).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(tblAppVersion)); }
public JsonResult SendEmailVerificationCode(string Email) { try { string message = string.Empty; var HasStudent = db.tblStudents.Where(x => x.FatherEmail == Email || x.MotherEmail == Email).Select(u => u.StudentId).ToList(); if (HasStudent.Count != 0) { var HasDuplicate = db.tblAppLogins.Where(x => x.Email == Email && x.IsRegistered == true).Select(x => new { x.Email }).SingleOrDefault(); if (HasDuplicate == null) { var Duplicate = db.tblAppLogins.Where(x => x.Email == Email).SingleOrDefault(); if (Duplicate == null) { tblAppLoginobj.Email = Email; string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random rand = new Random(); int size = 6; StringBuilder Passcode = new StringBuilder(); char[] chars = new char[size]; for (int i = 0; i < size; i++) { chars[i] = Alphabet[rand.Next(Alphabet.Length)]; Passcode.Append(chars[i]); } tblAppLoginobj.IsRegistered = false; tblAppLoginobj.Passcode = Passcode.ToString(); db.tblAppLogins.Add(tblAppLoginobj); db.SaveChanges(); string Body = "<html><body> Hi there! <br /><br /> Your Verification Code is:" + Passcode + "</body></html>"; string subject = "Verification Code"; EmailHelper.TrySendEmail(subject, Body, Email); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } else { string Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Random rand = new Random(); int size = 6; StringBuilder Passcode = new StringBuilder(); char[] chars = new char[size]; for (int i = 0; i < size; i++) { chars[i] = Alphabet[rand.Next(Alphabet.Length)]; Passcode.Append(chars[i]); } tblAppLoginobj.IsRegistered = false; Duplicate.Passcode = Passcode.ToString(); tblAppLoginobj.Passcode = Passcode.ToString(); db.Entry(Duplicate).State = EntityState.Modified; db.SaveChanges(); string Body = "<html><body> Hi there! <br /><br /> Your Verification Code is:" + Passcode + "</body></html>"; string subject = "Verification Code"; EmailHelper.TrySendEmail(subject, Body, Email); return(Json(new { status = true }, JsonRequestBehavior.AllowGet)); } } else { message = string.Format("Already Registered!"); return(Json(new { status = false, Message = message }, JsonRequestBehavior.AllowGet)); } } else { message = string.Format("Email Not Saved As Parents Email"); return(Json(new { status = false, Message = message }, JsonRequestBehavior.AllowGet)); } } catch (Exception e) { return(Json(new { status = false, Message = e.ToString() }, JsonRequestBehavior.AllowGet)); } }