public static void InserRememberIdPwdOption(bool isRemember) { using (mydbEntities db = new mydbEntities()) { var rememberIdPwdOption = db.tdcode.Where(t => t.code_id == Params.codeIdRememberIdPwd && t.code_type == Params.codeTypeRememberIdPwd).FirstOrDefault(); if (rememberIdPwdOption == null) { //insert hide browser option tdcode codeNew = new tdcode(); codeNew.code_id = Params.codeIdRememberIdPwd; codeNew.code_type = Params.codeTypeRememberIdPwd; codeNew.code_value = isRemember.ToString(); db.tdcode.Add(codeNew); db.SaveChanges(); } else { //update hide browser option rememberIdPwdOption.code_value = isRemember.ToString(); db.SaveChanges(); } } }
public static void InsertUserLoginIdPwdToDB(string unEncryptedId, string unEncryptedPwd) { string codeId = Params.codeIdLoginIdPwd; // "UserLoginIdPwd"; string codeType = Params.codeTypeAutoLogin; // "AutoLogin"; string notEncryptedStr = unEncryptedId + "," + unEncryptedPwd; string encryptedStr = Common.CryptEncryptString(notEncryptedStr); using (mydbEntities db = new mydbEntities()) { var loginObj = db.tdcode.Where(t => t.code_id == codeId && t.code_type == codeType).FirstOrDefault(); //if not exist => insert if (loginObj == null) { tdcode param = new tdcode(); param.code_id = codeId; param.code_type = codeType; param.code_value = encryptedStr; db.tdcode.Add(param); } else { //if exists => update loginObj.code_value = encryptedStr; } db.SaveChanges(); } }
public static void InserUpdateHideBrowserOption(bool isHide) { using (mydbEntities db = new mydbEntities()) { var hideBrowserOption = db.tdcode.Where(t => t.code_id == Params.codeIdHideBrowser && t.code_type == Params.codeTypeHideBrowser).FirstOrDefault(); if (hideBrowserOption == null) { //insert hide browser option tdcode codeNew = new tdcode(); codeNew.code_id = Params.codeIdHideBrowser; codeNew.code_type = Params.codeTypeHideBrowser; codeNew.code_value = isHide.ToString(); db.tdcode.Add(codeNew); db.SaveChanges(); } else { //update hide browser option hideBrowserOption.code_value = isHide.ToString(); db.SaveChanges(); } } }
public static void InserUpdateUserTTE(string userId, string newTTE) { using (mydbEntities db = new mydbEntities()) { var userTTE = db.tdcode.Where(t => t.code_id == userId && t.code_type == Params.codeTypeTTE).FirstOrDefault(); if (userTTE == null) { //insert user TTE tdcode codeNew = new tdcode(); codeNew.code_id = userId; codeNew.code_type = Params.codeTypeTTE; codeNew.code_value = newTTE; db.tdcode.Add(codeNew); db.SaveChanges(); } else { //update user FTP userTTE.code_value = newTTE; db.SaveChanges(); } } }
public static void InserUpdateDefaultLanguage(string userSelectLanguage) { using (mydbEntities db = new mydbEntities()) { //check if user select a default language var userSelectLanguageObj = db.tdcode .Where(t => t.code_id == Params.langCodeId && t.code_type == Params.langCodeType).FirstOrDefault(); if (userSelectLanguageObj != null) { //data exist: update data userSelectLanguageObj.code_value = userSelectLanguage; } else { //data not exist: insert data tdcode langSetting = new tdcode(); langSetting.code_id = Params.langCodeId; langSetting.code_type = Params.langCodeType; langSetting.code_value = userSelectLanguage; db.tdcode.Add(langSetting); } db.SaveChanges(); } }