public void SetUsers(USERS UsersUp) { MaderaEntities MaderaEntities = new MaderaEntities(); MaderaEntities.USERS.Add(UsersUp); MaderaEntities.SaveChanges(); }
/// <summary> /// Inserts the user. /// </summary> /// <param name="user">The user.</param> /// <returns></returns> public int insertUser(USERS user) { //mã hóa pass EncryptPassword encryptPass = new EncryptPassword(); string newPass = encryptPass.encrypt(user.password); //insert return dal.insertUser(user.email, user.firstName, user.lastName, newPass, user.type, user.status); }
// GET: USERS/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } USERS uSERS = db.USERS.Find(id); if (uSERS == null) { return(HttpNotFound()); } return(View(uSERS)); }
public ActionResult UserEdit(string id, USERS _users) { if (!GLOBALS.CookieAuth()) { return(RedirectToAction("Index", "Home")); } using (db) { db.Execute("update USERS set USERNAME='******',PASSWORD='******',CODE='" + _users.CODE + "'" + ",TEL='" + _users.TEL + "',TEL2='" + _users.TEL2 + "',EMAIL='" + _users.EMAIL + "'" + " where LOGICALREF=" + id + ""); } return(RedirectToAction("UserList")); }
private void LoadForm(USERS user) { ResetForm(); pnlSearch.Visible = pnlResult.Visible = false; pnlUserInfo.Visible = true; hideUserId.Value = user.USER_ID.ToString(); txtUsername.Text = user.USERNAME; txtFirstName.Text = user.FIRST_NAME; txtMiddleName.Text = user.MIDDLE_NAME; txtLastName.Text = user.LAST_NAME; txtFullName.Text = user.FULL_NAME; txtMaidenName.Text = user.MAIDEN_NAME; txtEmployeeNumber.Text = user.EMPLOYEE_NUMBER; txtJobTitle.Text = user.JOB_TITLE; txtEmailAddress.Text = user.EMAIL_ADDRESS; txtTelephoneNumber.Text = user.TELEPHONE_NUMBER; txtFaxNumber.Text = user.FAX_NUMBER; if (user.RECEIVE_EMAIL != null) { chkEmailAlerts.Checked = user.RECEIVE_EMAIL.Value; } if (rblSystemRoles.Items.Count <= 0) { rblSystemRoles.DataBind(); } if (rblSystemRoles.Items.Count > 0) { rblSystemRoles.SelectedIndex = 0; List <USER_ROLES> userRoles = ServiceInterfaceManager.USER_ROLES_GET_ALL_BY_USER(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, user.USER_ID); if (userRoles != null) { foreach (USER_ROLES userRole in userRoles) { foreach (ListItem li in rblSystemRoles.Items) { if (userRole.STD_ROLE_ID.ToString() == li.Value && !userRole.INACTIVE_FLAG) { li.Selected = true; } } } } UserRoles = userRoles; } }
public IHttpActionResult Delete(int id) { USERS item = db.USERS.Find(id); if (item == null) { return(NotFound()); } db.USERS.Remove(item); db.SaveChanges(); return(Ok()); }
public ActionResult DeleteConfirmed(int id) { try { USERS uSERS = db.USERS.Find(id); db.USERS.Remove(uSERS); db.SaveChanges(); } catch (Exception ex) { return(View("Error", new HandleErrorInfo(ex, "Forbidden_Action", "Delete"))); } return(RedirectToAction("Index")); }
public ActionResult UpdateUser(USERS p) { var ad = db.USERS.Find(p.User_ID); ad.User_ID = p.User_ID; ad.User_Name = p.User_Name; ad.User_Lastname = p.User_Lastname; ad.User_Nickname = p.User_Nickname; ad.User_Mail = p.User_Mail; ad.User_Password = p.User_Password; ad.User_Phone = p.User_Phone; db.SaveChanges(); return(RedirectToAction("Index")); }
/// <summary> /// Gets the number of appointments for the specified employee in the specified year and month /// </summary> /// <param name="employee"></param> /// <param name="monthNr"></param> /// <param name="year"></param> /// <returns></returns> public int GetEmployeeNumberOfAppointments(USERS employee, int monthNr, int year) { var allAppointments = GetAppointments(); List <APTDETAILS> appointmentsByEmployee = new List <APTDETAILS>(); foreach (var a in allAppointments) { if (a.APD_USER == employee.US_STAMP && a.APD_DATE.Value.Month == monthNr && a.APD_DATE.Value.Year == year) { appointmentsByEmployee.Add(a); } } return(appointmentsByEmployee.Count); }
public object check(USERS user) { var Data = db.USERS.Where(u => u.UserId == user.UserId).Select(s => s).FirstOrDefault(); if (Data != null) { ls.que = Data.Question; ls.ans = Data.Answer; return(ls); } else { return("4000"); } }
public ActionResult UserDelete(string id) { if (!GLOBALS.CookieAuth()) { return(RedirectToAction("Index", "Home")); } USERS _users = new USERS(); using (db) { _users = db.Query <USERS>("select * from USERS where LOGICALREF=" + id).SingleOrDefault(); } return(View(_users)); }
/// <summary> /// Gets the number of appointments for the specified employee /// </summary> /// <param name="employee"></param> /// <returns></returns> public int GetEmployeeNumberOfAppointments(USERS employee) { var allAppointments = GetAppointments(); List <APTDETAILS> appointmentsByEmployee = new List <APTDETAILS>(); foreach (var a in allAppointments) { if (a.APD_USER == employee.US_STAMP) { appointmentsByEmployee.Add(a); } } return(appointmentsByEmployee.Count); }
public ActionResult Giris(USERS usr) { OyuncakciEntities db = new OyuncakciEntities(); var model = db.USERS.Where(x => x.E_MAİL.Equals(usr.E_MAİL) && x.SIFRE.Equals(usr.SIFRE)).FirstOrDefault(); if (model != null) { return(RedirectToAction("Index", "Home")); } else { return(RedirectToAction("Index", "Login")); } }
static void ChangePasswordForUserForm() { string username = string.Empty; Console.Write("username:"******"no user found: {username}"); return; } ChangePasswordForm(user); }
List <USERS> GetDataUsers(SqlCommand cmd) { cmd.Connection.Open(); SqlDataReader reader = cmd.ExecuteReader(); List <USERS> list = new List <USERS>(); using (reader) { while (reader.Read()) { USERS obj = new USERS(); obj.ID = reader.GetInt32(0); Receiver_id = obj.ID; obj.NAME = reader.GetString(1); Receiver_name = obj.NAME; receiverImage = (byte[])(reader[2]); MemoryStream memoryStream = new MemoryStream(obj.IMAGE); obj.IMAGE = receiverImage; obj.DOB = reader.GetDateTime(3); Receiver_dob = obj.DOB; obj.GENDER = reader.GetString(4); Receiver_gender = obj.GENDER; obj.BLOOD_GROUP = reader.GetString(5); Receiver_bloodGroup = obj.BLOOD_GROUP; obj.ADDRESS = reader.GetString(6); Receiver_address = obj.ADDRESS; obj.CELLPHONE = reader.GetString(7); Receiver_cellphone = obj.CELLPHONE; obj.EMAIL = reader.GetString(8); Receiver_email = obj.EMAIL; obj.HEIGHT = reader.GetDouble(9); Donor_height = obj.HEIGHT; obj.WEIGHT = reader.GetDouble(10); Donor_weight = obj.WEIGHT; obj.DRUG_ADDICTION = reader.GetString(11); Donor_drugAddiction = obj.DRUG_ADDICTION; obj.HIV_STATUS = reader.GetString(12); Donor_HIV = obj.HIV_STATUS; obj.LAST_DONATION_DATE = reader.GetDateTime(13); Donor_lastDonationDate = obj.LAST_DONATION_DATE; list.Add(obj); } reader.Close(); } cmd.Connection.Close(); return(list); }
public static LoginResponse Authenticate(Login login) { // Ensure that we have what we need if (login == null || string.IsNullOrEmpty(login.Email) || string.IsNullOrEmpty(login.Password)) { return(null); } USERS loginUser = null; // Read directly from the database; UserManager does not read password and salt, in order to keep them more private using (var db = new CSET_Context()) { loginUser = db.USERS.Where(x => x.PrimaryEmail == login.Email).FirstOrDefault(); if (loginUser == null) { return(null); } } // Validate the supplied password against the hashed password and its salt bool success = PasswordHash.ValidatePassword(login.Password, loginUser.Password, loginUser.Salt); if (!success) { return(null); } // Generate a token for this user string token = TransactionSecurity.GenerateToken(loginUser.UserId, login.TzOffset, -1, null, null, login.Scope); // Build response object LoginResponse resp = new LoginResponse { Token = token, UserId = loginUser.UserId, Email = login.Email, UserFirstName = loginUser.FirstName, UserLastName = loginUser.LastName, IsSuperUser = loginUser.IsSuperUser, ResetRequired = loginUser.PasswordResetRequired ?? true, ExportExtension = IOHelper.GetExportFileExtension(login.Scope), ImportExtensions = IOHelper.GetImportFileExtensions(login.Scope) }; return(resp); }
public ActionResult AdminLogin(USERS model) { USERS user = new USERS(); user = dbContext.USERS.Where(i => i.USERNAME == model.USERNAME & i.PASSWORD == model.PASSWORD).FirstOrDefault(); if (user == null) { return(View()); } else { Session["username"] = model.USERNAME; Session["id"] = model.ID; return(RedirectToAction("ListProduct")); } }
public ActionResult UserDetails(USERS user) { if (user.Username == null) { ModelState.AddModelError(string.Empty, "Invalid USER Name"); } if (ModelState.IsValid) { database.Entry(user).Entity.Inactive = user.Inactive; database.Entry(user).Entity.LastModified = System.DateTime.Now; database.Entry(user).State = EntityState.Modified; database.SaveChanges(); } return(View(user)); }
public static USERS getUser(int idUser) { USERS user = null; try { using (goliazco_FWEntities entity = new goliazco_FWEntities()) { user = (from t in entity.USERS where t.idUser == idUser select t).FirstOrDefault(); } } catch (Exception ex) { } return(user); }
// GET: USERS/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } USERS uSERS = db.USERS.Find(id); if (uSERS == null) { return(HttpNotFound()); } ViewBag.PROJECT_ID = new SelectList(db.PROJECT, "PROJECT_ID", "PROJECT_ID", uSERS.PROJECT_ID); ViewBag.ROLE_TYPE = new SelectList(db.ROLES, "ROLE_TYPE", "ROLE_TYPE", uSERS.ROLE_TYPE); return(View(uSERS)); }
public async Task <ActionResult> Signup(FormCollection signupAccount) { string c = signupAccount["Username"]; var v = _meditech.USERS.Where(a => a.USERNAME.Equals(c)).FirstOrDefault(); if (v == null) { USERS ac = new USERS(); ac.USERNAME = signupAccount["Username"]; ac.PASSWORD = c = GetMD5HashData(signupAccount["Password"]); _meditech.USERS.Add(ac); _meditech.SaveChanges(); return(RedirectToAction("Login", "Account")); } return(View("Signup")); }
protected override void Page_Load(object sender, EventArgs e) { //adding line of commented text for RTC Task 350744 UserSession.Refresh(); if (!Page.IsPostBack) { ServiceInterfaceManager.LogInformation("PAGE_LOAD", String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId); } try { base.Page_Load(sender, e); //BuildMenu(); if (!Page.IsPostBack) { USERS user = ServiceInterfaceManager.USERS_GET_BY_NAME(HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId, HttpContext.Current.User.Identity.Name); if (user != null) { UserSession.DefautRegistryId = user.DEFAULT_REGISTRY_ID; } if (UserSession.DefautRegistryId > 0) { // UserSession.DefautRegistryId = user.DEFAULT_REGISTRY_ID; Response.Redirect("~/Common/Default.aspx?id=" + UserSession.DefautRegistryId, false); } else { SETTINGS setting = ServiceInterfaceManager.GET_HOME_PAGE_SETTING(); if (setting != null && !string.IsNullOrEmpty(setting.VALUE)) { lblDescription.Text = setting.VALUE; } else { lblDescription.Text = "Welcome to the Converged Registries Solution home page."; } } } } catch (Exception ex) { ServiceInterfaceManager.LogError(ex.Message, String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name), HttpContext.Current.User.Identity.Name, UserSession.CurrentRegistryId); throw ex; } }
/// <summary> /// Method that allow send a message to confirm email /// </summary> /// <returns>true or false if was sent</returns> public bool SendConfirmEmailMessage(USERS userNew, out string mensajeError) { //Mensaje de correo bool sentMessage = false; mensajeError = ""; try { MailMessage mensaje = new MailMessage(); mensaje.From = new MailAddress(infoEmail); MailAddress para = new MailAddress(userNew.email); mensaje.To.Add(para); mensaje.Subject = "Goliaz Challenge, Please Confirm your Email."; string codigo = GetRandomHexNumber(10); userNew = UserDao.updateUser(userNew, codigo); if (!string.IsNullOrEmpty(userNew.codeConfirm)) { mensaje.IsBodyHtml = true; string urlConfirm = "http://goliaz.com/confirmEmail.aspx?code=" + HttpUtility.UrlEncode(codigo) + "&em=" + userNew.email; //mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body style='font-size: 15px !important;font-family: Arial,sans-serif;'>Dear " + userNew.name + ", <br/><br/> Congratulations and welcome to Goliaz Challenge. Please click <a href='http://goliaz.com/confirmEmail.aspx?code=" + codigo + "&em=" + userNew.email + "' >here</a> to confirm your email address to finish the register process.<br/><br/>Regards,<br/>Goliaz Challenge Team. <br/><br/><img alt='goliaz.com' src='http://goliaz.com/images/image.jpg' /></body></html>"; mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body style='font-size: 15px !important;font-family: Arial,sans-serif;'>Dear " + userNew.name + ", <br/><br/> Congratulations and welcome to the Goliaz Challenge!<br/><br/>Please click <a href='" + urlConfirm + "' >here</a> to confirm your email address and to finish the registration process.<br/><br/>Regards,<br/>Goliaz Challenge Team. <br/><br/><img alt='goliaz.com' src='http://goliaz.com/images/logomask2.png' style='width:200px;' /></body></html>"; //mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body>Dear " + userNew.name + ", <br/> Please go to http://goliaz.com/confirmEmail.aspx?code=" + codigo + "&em=" + userNew.email + " to confirm your email.<br/><br/>Regards,<br/>Goliaz Challenge Team.</body></html>"; //Configuracion cliente SMTP SmtpClient cliente = new SmtpClient(serverAddress, portSendmail); //cliente.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis; cliente.UseDefaultCredentials = false; cliente.Credentials = new System.Net.NetworkCredential(infoEmail, passEmail); //Send message cliente.Send(mensaje); sentMessage = true; } } catch (SmtpException ex) { //throw new Exception(ex.Message); mensajeError = ex.InnerException.Message; } return(sentMessage); }
private void log_in_button_login_page_Click(object sender, EventArgs e) { if (!string.IsNullOrWhiteSpace(input_username_userlist_page.Text) && !string.IsNullOrWhiteSpace(input_password_userlist_page.Text) && !string.IsNullOrWhiteSpace(input_confirm_password_userlist_page.Text)) { USERS user = null; using (testWinFormDBEntities dbcontext = new testWinFormDBEntities()) { user = dbcontext.USERS.Where(s => s.USERNAME == input_username_userlist_page.Text).FirstOrDefault <USERS>(); if (user != null) { if (input_password_userlist_page.Text == input_confirm_password_userlist_page.Text) { user.PASSWORD = input_password_userlist_page.Text; try { dbcontext.Entry(user).State = System.Data.Entity.EntityState.Modified; dbcontext.SaveChanges(); MessageBox.Show("Şifrəniz uğurla yeniləndi !"); input_username_userlist_page.Text = ""; input_password_userlist_page.Text = ""; input_confirm_password_userlist_page.Text = ""; } catch (Exception ex) { MessageBox.Show("Şifrə yenilənərkən xəta baş verdi ! " + ex.Message); } } else if (input_password_userlist_page.Text != input_confirm_password_userlist_page.Text) { MessageBox.Show("Daxil etdiyiniz şifrələr bir biri ilə uyğun gəlmir. \nZəhmət olmasa şifrələri yoxlayın və yenidən cəhd edin"); } } else if (user == null) { MessageBox.Show("Daxil etdiyiniz adda istifadəçi yoxdur !"); } } } else { MessageBox.Show("Xanalar boşdur. Xanaları doldurub yenidən cəhd edin !"); } }
/// <summary> /// Creates a new USER record. Generates a temporary password and /// returns it as part of the response. /// If a User already exists for the specified email, an exception is throw /// please check for existence before calling this if you do not intent /// to create a user. /// </summary> /// <returns></returns> public UserCreateResponse CreateUser(UserDetail userDetail) { // see if this user already exists UserDetail existingUser = this.GetUserDetail(userDetail.Email); if (existingUser != null) { // USER ALREADY EXISTS ... return what we already have // NO we better return an error so that someone cannot just overwrite the account // prompt them to recover the password if the account already exists throw new ApplicationException("This user already exists. To recover a password user the forgot password link on the login page."); } // generate and hash a temporary password string temporaryPassword = System.Web.Security.Membership.GeneratePassword(10, 2); string hashedPassword; string salt; PasswordHash.HashPassword(temporaryPassword, out hashedPassword, out salt); // create new records for USER and USER_DETAIL_INFORMATION using (var db = new CSET_Context()) { var u = new USERS() { PrimaryEmail = userDetail.Email, FirstName = userDetail.FirstName, LastName = userDetail.LastName, Password = hashedPassword, Salt = salt, IsSuperUser = false, PasswordResetRequired = true }; db.USERS.Add(u); db.SaveChanges(); UserCreateResponse resp = new UserCreateResponse { UserId = u.UserId == 0?1:u.UserId, PrimaryEmail = u.PrimaryEmail, TemporaryPassword = temporaryPassword }; return(resp); } }
public bool insertUsersReceiver(USERS obj) { int val = 0; try { SqlDbDataAccess da = new SqlDbDataAccess(); SqlCommand cmd = da.GetCommand("INSERT INTO [dbo].[USERS] ([ID],[NAME],[IMAGE], [DOB], [GENDER], [BLOOD_GROUP], [ADDRESS], [CELLPHONE], [EMAIL]) VALUES (@ID, @NAME, @IMAGE, @DOB, @GENDER, @BLOOD_GROUP, @ADDRESS, @CELLPHONE, @EMAIL)"); SqlParameter p = new SqlParameter("@ID", SqlDbType.Int); p.Value = obj.ID; SqlParameter p1 = new SqlParameter("@NAME", SqlDbType.VarChar, 50); p1.Value = obj.NAME; SqlParameter p2 = new SqlParameter("@IMAGE", SqlDbType.Image); p2.Value = obj.IMAGE; SqlParameter p3 = new SqlParameter("@DOB", SqlDbType.Date); p3.Value = obj.DOB; SqlParameter p4 = new SqlParameter("@GENDER", SqlDbType.VarChar, 6); p4.Value = obj.GENDER; SqlParameter p5 = new SqlParameter("@BLOOD_GROUP", SqlDbType.VarChar, 3); p5.Value = obj.BLOOD_GROUP; SqlParameter p6 = new SqlParameter("@ADDRESS", SqlDbType.VarChar, 50); p6.Value = obj.ADDRESS; SqlParameter p7 = new SqlParameter("@CELLPHONE", SqlDbType.VarChar, 11); p7.Value = obj.CELLPHONE; SqlParameter p8 = new SqlParameter("@EMAIL", SqlDbType.VarChar, 50); p8.Value = obj.EMAIL; cmd.Parameters.Add(p); cmd.Parameters.Add(p1); cmd.Parameters.Add(p2); cmd.Parameters.Add(p3); cmd.Parameters.Add(p4); cmd.Parameters.Add(p5); cmd.Parameters.Add(p6); cmd.Parameters.Add(p7); cmd.Parameters.Add(p8); cmd.Connection.Open(); val = cmd.ExecuteNonQuery(); cmd.Connection.Close(); } catch (Exception ex) { } return(val > 0); }
private void setInstance(USERS user) { if (user == null) { return; } this.user = user; needApprove = user.NEED_APPROVE; parents = GetParents(); classes = GetClasses(); groups = GetGroups(); subjects = GetSubjects(); children = GetChildren(); students = GetStudents(); }
public ActionResult YeniUye(USERS usr) { if (usr.ID == 0) { using (OyuncakciEntities db = new OyuncakciEntities()) { db.USERS.Add(usr); db.SaveChanges(); } return(RedirectToAction("Index", "Login")); } else { return(RedirectToAction("Index", "Uyelik")); } }
public static USERS validateUser(USERS user) { try { using (goliazco_FWEntities entity = new goliazco_FWEntities()) { user = (from t in entity.USERS where t.idUser == user.idUser select t).FirstOrDefault(); user.estado = "Confirmed"; entity.SaveChanges(); } } catch (Exception ex) { throw new Exception(ex.Message); } return(user); }
public static USERS loginUser(string email, string pass) { USERS getLogedUser = null; try { using (goliazco_FWEntities entity = new goliazco_FWEntities()) { getLogedUser = (from t in entity.USERS where t.email == email && t.pass == pass select t).FirstOrDefault(); } } catch (Exception ex) { throw new Exception(ex.Message); } return(getLogedUser); }
public ActionResult login(String nick, String password) { USERS user = repoLogin.GetUser(nick, password); if (user != null) { FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, user.ID, DateTime.Now, DateTime.Now.AddMinutes(30), true, user.ROLE); String ticketEncrypt = FormsAuthentication.Encrypt(ticket); HttpCookie cookie = new HttpCookie("PICTUREMANAGER", ticketEncrypt); Response.Cookies.Add(cookie); return(RedirectToAction("menu", "admin")); } else { ViewBag.Mensaje = "Usuario/Password incorrectos."; } return(View()); }
public ActionResult UserEdit(string id, string fromAdd) { if (!GLOBALS.CookieAuth()) { return(RedirectToAction("Index", "Home")); } USERS _users = new USERS(); if (fromAdd == "1") { TempData["msg"] = "<script>alert('Bu Firmanın Kullanıcısı Mevcut Güncelleme Yapabilirsiniz!!!');</script>"; } using (db) { _users = db.Query <USERS>("select * from USERS where LOGICALREF=" + id).SingleOrDefault(); } return(View(_users)); }