public JsonResult checkUsernameExists(ValidateAccountRequest req) { var _db = new ZestorkContainer(); if (_db.Users.Any(x => x.Username == req.userName)) { return Json(new { code = "402", msg = "username already exists" }); } else { return Json(new { code = "200", msg = "this is a new username" }); } }
public JsonResult validateAccount(ValidateAccountRequest req) { var _db = new ZestorkContainer(); if (_db.ValidateUserKeys.Any(x => x.Username == req.userName && x.guid == req.guid)) { Users User = _db.Users.SingleOrDefault(x => x.Username == req.userName); User.isActive = "true"; try { _db.SaveChanges(); } catch (DbEntityValidationException e) { dbContextException.logDbContextException(e); throw; } return Json(new { code = "200", msg = "account validated successfully" }); } else { return Json(new { code = "402", msg = "Link might be expired" }); } }