public bool AuthTest(string username, string password, ref userType theUser) { bool autorised = false; OpenConnection(); Console.WriteLine("Debugging:"); soHigh(username, ref password); sqlCmd.CommandText = string.Format("select StaffName, Password, StaffTypeID, StaffID from Staff WHERE StaffName='{0}' AND Password='******';", username, password); sqlCmd.Connection = dbConnection; reader = sqlCmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); if ((username == reader.GetString(0)) && (password == reader.GetString(1))) { userid = reader.GetInt32(3); theUser = (userType)reader.GetInt32(2); autorised = true; } } if(debugging){ AuthDebugging(username, password); } CloseConnection(); return autorised; }
public IEnumerable <PaymentAccount> Get(string userID, userType type)//gets all the accounts and its details for a specific User or beneficiary { if (type == userType.Client) { PaymentAccount pa = new PaymentAccount { UserID = userID }; Dictionary <Expression <Func <PaymentAccount, object> >, Func <PaymentAccount, object> > Filters = new Dictionary <Expression <Func <PaymentAccount, object> >, Func <PaymentAccount, object> >(); Filters.Add(c => c.UserID, c => c.UserID); List <PaymentAccount> us = DatabaseHandler <PaymentAccount> .getDocumentContent(pa, Filters); return(us); } else { PaymentAccount pa = new PaymentAccount { BeneficiaryID = userID }; Dictionary <Expression <Func <PaymentAccount, object> >, Func <PaymentAccount, object> > Filters = new Dictionary <Expression <Func <PaymentAccount, object> >, Func <PaymentAccount, object> >(); Filters.Add(c => c.BeneficiaryID, c => c.BeneficiaryID); List <PaymentAccount> us = DatabaseHandler <PaymentAccount> .getDocumentContent(pa, Filters); return(us); } }
public IEnumerable <Crypto> Get(string userID, userType type)//gets all the accounts and its details for a specific User or beneficiary { if (type == userType.Client) { Crypto pa = new Crypto { UserId = userID }; Dictionary <Expression <Func <Crypto, object> >, Func <Crypto, object> > Filters = new Dictionary <Expression <Func <Crypto, object> >, Func <Crypto, object> >(); Filters.Add(c => c.UserId, c => c.UserId); List <Crypto> us = DatabaseHandler <Crypto> .getDocumentContent(pa, Filters); return(us); } else { Crypto pa = new Crypto { BeneficiaryId = userID }; Dictionary <Expression <Func <Crypto, object> >, Func <Crypto, object> > Filters = new Dictionary <Expression <Func <Crypto, object> >, Func <Crypto, object> >(); Filters.Add(c => c.BeneficiaryId, c => c.BeneficiaryId); List <Crypto> us = DatabaseHandler <Crypto> .getDocumentContent(pa, Filters); return(us); } }
public ActionResult DeleteConfirmed(int id) { userType userType = db.userType.Find(id); db.userType.Remove(userType); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "userTypeID,userType1")] userType userType) { if (ModelState.IsValid) { db.Entry(userType).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userType)); }
public ActionResult Create([Bind(Include = "userTypeID,userType1")] userType userType) { if (ModelState.IsValid) { db.userType.Add(userType); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(userType)); }
public bool ChangeType(string id, userType type) { int index = users.FindIndex(delegate(User u) { return(u.ID == id); }); if (index == -1) { return(false); } users[index].Type = type; return(true); }
// GET: userTypes/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } userType userType = db.userType.Find(id); if (userType == null) { return(HttpNotFound()); } return(View(userType)); }
public teachingStaffMenu(user someUser) { InitializeComponent(); labelNoSched.Hide(); //learn more about downcasting here http://stackoverflow.com/questions/1524197/downcast-and-upcast if (someUser is professor) { //make reperance to the object we get this.prof = (professor)someUser; theUserWeGot = userType.Professor; } if (someUser is instructor) { //make reperance to the object we get this.inst = (instructor)someUser; theUserWeGot = userType.Instructor; } //change this form size //see also: https://msdn.microsoft.com/en-us/library/ms229606(v=vs.110).aspx this.Size = new System.Drawing.Size(1000, 550); //set position in the center; //see also: https://msdn.microsoft.com/en-us/library/system.windows.forms.form.startposition(v=vs.110).aspx this.StartPosition = FormStartPosition.CenterScreen; //set the item in the combo boxes setComboBoxes(); set_account_Management(); //hide constraints panel; panel1.Hide(); //build schedule if the schedule is published by the secretary if (new dataBaseOperations().getPublishedSched(someUser.getid())) { build_schedule(someUser); } else { labelNoSched.Show(); } watch_your_constraints(null, null); }
public static User userFactory(userType type) { switch (type) { case userType.Driver: return(new Driver()); case userType.Salesman: return(new Salesman()); case userType.Customer: return(new Customer()); default: return(null); } }
public static User userFactory(userType type, String username, String password) { switch (type) { case userType.Driver: return(new Driver(username, password)); case userType.Salesman: return(new Salesman(username, password)); case userType.Customer: return(new Customer(username, password)); default: return(null); } }
//public int idStudent { get; set; } //[ForeignKey("Student")] //public virtual Student Student { get; set; } public User(string username, string password, string name, string surname, string type) { this.username = username; this.password = password; this.name = name; this.surname = surname; if (type == "student") { this.type = userType.student; } else if (type == "referent") { this.type = userType.referent; } else if (type == "profesor") { this.type = userType.profesor; } }
public Boolean isCustomer(userType type, String username, String password) { user = UserFactory.userFactory(type); String usr = user.viewUsername(username); if (usr == "CTS-Invalid") { return(false); } String pwd = user.getPassword(username); if (password != "Override-Code1111") { if (pwd == "CTS-Invalid" || pwd != password) { return(false); } this.username = usr; this.firstName = user.getFirstName(usr); lastName = user.getLastName(usr); } return(true); }
public static void addUser(userType type, String username, String password, String confirm) { newuser = FactoryModel.userFactory(type, username, password); StartWebsite.userList.Add(newuser); }
public bool ChangeUserType(string ID, userType NewType) { return(UsersList.ChangeType(ID, NewType)); }
static public void setCurrentUserType(userType type) { currentType = type; }
public bool Register(userType user, string username, string password, string firstName, string lastName, string email) { bool succsess = false; bool usernameExists = false; firstName = "First"; lastName = "Last"; SqlCommand register = null; OpenConnection(); soHigh(username, ref password); sqlCmd.CommandText = string.Format("select StaffName from Staff WHERE StaffName='{0}';", username); sqlCmd.Connection = dbConnection; reader = sqlCmd.ExecuteReader(); if (reader.HasRows) { reader.Read(); if (username == reader.GetString(0)) { usernameExists = true; } } CloseConnection(); if (!usernameExists && (int)user != -1) { register = new SqlCommand(string.Format("INSERT Staff (StaffName, Password, StaffTypeID, FirstName, LastName, Email)" + "Values('{0}','{1}','{2}','{3}','{4}','{5}')", username, password, (int)user, firstName, lastName, email), dbConnection); OpenConnection(); register.ExecuteNonQuery(); CloseConnection(); } else { // user already exists error Console.WriteLine("user already exists"); } CloseConnection(); return succsess; }