public IActionResult Login(US_USER _obj, string nexturl) { try { //FormsAuthentication.SetAuthCookie(user.LOGIN_ID.ToUpper().Trim(), false); if (_obj.LOGIN_ID == null || _obj.PASSWORD == null) { TempData["message"] = "Enter Valid Information !!!"; return(View(_obj)); } string userId = _obj.LOGIN_ID.ToLower().Trim(); string userPass = TextEncryption.EncryptionWithSh(_obj.PASSWORD); US_USER _data = _unitOfWork.US_USER.GetFirstOrDefult(x => x.LOGIN_ID.ToLower() == userId && x.PASSWORD == userPass && x.IS_ACTIVE == true); if (_data == null) { TempData["message"] = "Enter Valid Information !!!"; return(View(_obj)); } else { HttpContext.Session.SetInt32("sessionID", _data.ID); HttpContext.Session.SetString("sessionLOGIN_ID", _data.LOGIN_ID); //LeaderBoard(); Index(); } } catch (Exception ex) { TempData["message"] = ex.Message.ToString(); return(View(_obj)); } return(RedirectToLocal(nexturl)); }
//[AllowAnonymous] public IActionResult Login(string nexturl) { //FormsAuthentication.SignOut(); //ViewBag.ReturnUrl = returnUrl; US_USER obj = new US_USER(); obj.LOGIN_ID = "admin"; obj.PASSWORD = "******"; return(View(obj)); }
public IActionResult ManageUser(US_USER _obj) { bool success_upload = false; string file_name = string.Empty; try { if (_obj.PROFILE_IMAGE_FILE != null) { string fname = Path.GetFileName(_obj.PROFILE_IMAGE_FILE.FileName); file_name = Path.GetFileNameWithoutExtension(fname) + "_" + Guid.NewGuid().ToString().Substring(0, 4) + Path.GetExtension(fname); var uploads = Path.Combine(_hostEnvironment.WebRootPath, "uploads\\userprofiles"); var filePath = Path.Combine(uploads, file_name); _obj.PROFILE_IMAGE_FILE.CopyTo(new FileStream(filePath, FileMode.Create)); } success_upload = true; } catch { success_upload = false; } if (ModelState.IsValid) { if (success_upload) { _obj.PROFILE_IMAGE = file_name; } if (_obj.ID == 0) { _obj.ID = _unitOfWork.US_USER.GetAll().Max(x => x.ID) + 1; _obj.PASSWORD = TextEncryption.EncryptionWithSh(_obj.PASSWORD); _obj.IS_ACTIVE = true; _unitOfWork.US_USER.Add(_obj); } else { if (string.IsNullOrWhiteSpace(_obj.PASSWORD)) { _obj.PASSWORD = TextEncryption.EncryptionWithSh(_obj.PASSWORD); } _unitOfWork.US_USER.Update(_obj); } _unitOfWork.Save(); TempData["msg"] = SweetMsg.SaveSuccess(); return(RedirectToAction(nameof(ManageUser))); } TempData["msg"] = SweetMsg.SaveErrorOK(); DropDownFor_ManageUser(); return(View(_obj)); }
public IActionResult ManageUser(int?id) { DropDownFor_ManageUser(); US_USER _obj = new US_USER(); _obj.DATE_OF_BIRTH = DateTime.Now; if (id != null) { _obj = _unitOfWork.US_USER.Get(id.Value); if (_obj == null) { TempData["msg"] = SweetMsg.SaveWarningOK(); } } return(View(_obj)); }