public ActionResult UserAktivasi(String id = "") { ViewData["moduleId"] = moduleId; var cekCountUserByCodeActivate = portaldb.SYS_USER_PUBLIC.SqlQuery("SELECT * FROM SYS_USER_PUBLIC WHERE USER_PUBLIC_ACTIVATION_KEY = '" + id + "' AND USER_PUBLIC_STATUS = 0 ").Count(); //return Json(new { test = cekCountUserByCodeActivate }, JsonRequestBehavior.AllowGet); //var userPublic = var getDateRegByCodeActivate = (from userpublic in portaldb.SYS_USER_PUBLIC where userpublic.USER_PUBLIC_ACTIVATION_KEY == id select userpublic).SingleOrDefault(); var getUIdRegByUsrRefId = (from usersys in portaldb.SYS_USER where usersys.USER_REF_ID == getDateRegByCodeActivate.USER_PUBLIC_ID && usersys.USER_TYPE_ID == 3 select usersys).SingleOrDefault(); var TimetoString = ((DateTime)getDateRegByCodeActivate.USER_PUBLIC_CREATE_DATE).ToString("yyyy-MM-dd HH:mm:ss"); DateTime dt2 = DateTime.ParseExact(TimetoString, "yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture); TimeSpan timeSince = DateTime.Now.Subtract(dt2); var totalJamAktivasi = (int)timeSince.TotalHours; ViewData["Message"] = ""; //ViewData["Message"] = cekCountUserByCodeActivate + " - " + totalJamAktivasi; if (cekCountUserByCodeActivate == 1 && totalJamAktivasi <= 24) { var datenow = MixHelper.ConvertDateNow(); var logcode = MixHelper.GetLogCode(); var fupdate1 = "USER_STATUS = '1'," + "USER_UPDATE_BY = '" + getUIdRegByUsrRefId.USER_ID + "'," + "USER_UPDATE_DATE = " + datenow; var fupdate2 = "USER_PUBLIC_STATUS = '1'," + "USER_PUBLIC_UPDATE_BY = '" + getUIdRegByUsrRefId.USER_ID + "'," + "USER_PUBLIC_UPDATE_DATE = " + datenow; portaldb.Database.ExecuteSqlCommand("UPDATE SYS_USER SET " + fupdate1 + " WHERE USER_ID = " + getUIdRegByUsrRefId.USER_ID); portaldb.Database.ExecuteSqlCommand("UPDATE SYS_USER_PUBLIC SET " + fupdate2 + " WHERE USER_PUBLIC_ID = " + getDateRegByCodeActivate.USER_PUBLIC_ID); String objek = fupdate2.Replace("'", "-"); MixHelper.InsertLogActivate(logcode, (int)getUIdRegByUsrRefId.USER_ID, (int)getUIdRegByUsrRefId.USER_ACCESS_ID, objek, 2); ViewData["Note"] = "note-success"; ViewData["Message"] = "Akun anda berhasil diaktivasi, silahkan login dengan menggunakan username dan password yang sudah kami kirimkan ke email"; //TempData["NotifSukses"] = "Akun anda berhasil diaktivasi, silahkan login dengan menggunakan username dan password yang sudah kami kirimkan ke email"; return(RedirectToAction("index", "auth")); } else { ViewData["Note"] = "note-danger"; ViewData["Message"] = "Maaf, Kode Aktivasi anda sudah kadaluarsa karena anda tidak melakukan aktivasi akun anda selama 24 jam. Silahkan menghubungi Team Support kami untuk mengaktivasi akun anda."; } return(View()); }