public ActionResult Login(string username = "", string password = "") { string passwordGen = GenPassword(password); var DATAUSER = new VIEW_USERS(); if (password == "sispkMCS") { DATAUSER = db.Database.SqlQuery <VIEW_USERS>("SELECT * FROM VIEW_USERS WHERE USER_NAME = '" + username + "' AND USER_STATUS = 1 AND ROWNUM = 1").SingleOrDefault(); } else { DATAUSER = db.Database.SqlQuery <VIEW_USERS>("SELECT * FROM VIEW_USERS WHERE USER_NAME = '" + username + "' AND USER_PASSWORD = '******' AND USER_STATUS = 1 AND ROWNUM = 1").SingleOrDefault(); } //var DATAUSER = (from it in db.VIEW_USERS where it.USER_NAME == username && it.USER_PASSWORD == passwordGen && it.USER_STATUS == 1 select it).SingleOrDefault(); if (DATAUSER != null) { Session["USER_ID"] = DATAUSER.USER_ID; Session["USER_NAME"] = DATAUSER.USER_NAME; Session["USER_ACCESS_ID"] = DATAUSER.USER_ACCESS_ID; //Session["USER_FIRST_NAME"] = DATAUSER.USER_FIRST_NAME; //Session["USER_LAST_NAME"] = DATAUSER.USER_LAST_NAME; Session["USER_FULL_NAME"] = DATAUSER.USER_FULL_NAME; Session["ACCESS_NAME"] = DATAUSER.ACCESS_NAME; Session["BIDANG_ID"] = DATAUSER.ACCESS_BIDANG_ID; //for session komtek Session["IS_KOMTEK"] = ((DATAUSER.USER_TYPE_ID == 2) ? 1 : 0); Session["KOMTEK_ID"] = DATAUSER.USER_KOMTEK_ID; Session["KOMTEK_CODE"] = DATAUSER.USER_KOMTEK_KODE; Session["KOMTEK_NAME"] = DATAUSER.USER_KOMTEK_NAMA; Session["KOMTEK_SEKRE"] = DATAUSER.USER_KOMTEK_IS_SEKRE; db.Database.ExecuteSqlCommand("UPDATE SYS_USER SET USER_IS_ONLINE = 1, USER_LAST_LOGIN = CURRENT_DATE WHERE USER_ID = '" + DATAUSER.USER_ID + "'"); //var DefaultMenu = DATAUSER.SYS_ACCESS.SYS_MENU.MENU_URL; //return Redirect(DefaultMenu); return(RedirectToAction("index", new RouteValueDictionary(new { tipe = "Home", controller = "Dashboard", action = "index" }))); } else { TempData["IsError"] = 1; return(RedirectToRoute("Default", null)); } }
public ActionResult Approve(VIEW_USERS_PUBLIC up) { int id = Convert.ToInt32(up.USER_PUBLIC_ID); var query = "UPDATE SYS_USER_PUBLIC SET USER_PUBLIC_STATUS = 1 WHERE USER_PUBLIC_ID = " + id; db.Database.ExecuteSqlCommand(query); VIEW_USERS user_item = db.VIEW_USERS.SingleOrDefault(t => t.USER_REF_ID == id && t.USER_ACCESS_ID == 4); var query1 = "UPDATE SYS_USER SET USER_STATUS = 1 WHERE USER_ID = " + user_item.USER_ID; db.Database.ExecuteSqlCommand(query1); var sysuser_public = (from s in db.SYS_USER_PUBLIC where s.USER_PUBLIC_ID == id select s).SingleOrDefault(); //var sysuser = (from t in db.SYS_USER where t.USER_REF_ID == sysuser_public.USER_PUBLIC_ID select t).SingleOrDefault(); //Send Account Activation to Email var email = (from t in db.SYS_EMAIL where t.EMAIL_IS_USE == 1 select t).SingleOrDefault(); var link = (from s in db.SYS_LINK where s.LINK_IS_USE == 1 select s).SingleOrDefault(); SendMailHelper.MailUsername = email.EMAIL_NAME; //"*****@*****.**"; SendMailHelper.MailPassword = email.EMAIL_PASSWORD; //"r4h45143uy"; SendMailHelper mailer = new SendMailHelper(); mailer.ToEmail = sysuser_public.USER_PUBLIC_EMAIL; mailer.Subject = "Konfirmasi Member Baru - Sistem Informasi SNI"; var isiEmail = "Terimakasih telah Melakukan Registrasi pada sistem kami. Berikut Data Detail anda : <br />"; isiEmail += "Username : "******"<br />"; isiEmail += "Status : Aktif <br />"; isiEmail += "Silahkan klik tautan <a href='" + link.LINK_NAME + "/auth/index' target='_blank'>berikut</a> untuk login<br />"; isiEmail += "Demikian Informasi yang kami sampaikan, atas kerjasamanya kami ucapkan terimakasih. <br />"; isiEmail += "<span style='text-align:right;font-weight:bold;margin-top:20px;'>Web Administrator</span>"; mailer.Body = isiEmail; mailer.IsHtml = true; mailer.Send(); TempData["Notifikasi"] = 1; TempData["NotifikasiText"] = "Data Berhasil Di Setujui"; return(RedirectToAction("Index")); }