private void btnLogin_Click(object sender, EventArgs e) { using (var Dbconnection = new MCDEntities()) { //check to see if it is System Admin Login SystemAdministrator LocalSystemAdmin = (from a in Dbconnection.SystemAdministrators select a).FirstOrDefault <SystemAdministrator>(); if (LocalSystemAdmin.SystemUserName.ToLower().Equals(txtUserName.Text.ToLower().ToString())) { //check the password if (LocalSystemAdmin.SystemUserPassword == txtPassword.Text.ToString()) { SystemAdminLogin = LocalSystemAdmin; } } //check to see if username exists List <Impendulo.Data.Models.Login> LoginDetails = (from a in Dbconnection.Logins select a) .Include("Employee") .Include("Employee.Individual") .Include("Employee.Individual.ContactDetails") .ToList <Impendulo.Data.Models.Login>(); foreach (Impendulo.Data.Models.Login CurrentLoginDetails in LoginDetails) { if (CurrentLoginDetails.UserName.ToLower().Equals(txtUserName.Text.ToLower())) { //User Details Found if (CurrentLoginDetails.Password.Equals(txtPassword.Text)) { //Password matchs CurrentEmployee = CurrentLoginDetails.Employee; } } } // checked password if user found if (SystemAdminLogin != null || CurrentEmployee != null) { MCDMainForm frm = new MCDMainForm(); if (this.CurrentEmployee != null) { frm.CurrentEmployeeLoggedIn = this.CurrentEmployee; this.Hide(); frm.ShowDialog(); this.Close(); } else { frm.SystemAdminLogin = this.SystemAdminLogin; this.Hide(); frm.ShowDialog(); this.Close(); } } else { MessageBox.Show("User Name and Password Incorrect Or Not Found!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } }; }
public ActionResult DeleteConfirmed(int id) { SystemAdministrator systemAdministrator = db.SystemAdministrators.Find(id); db.SystemAdministrators.Remove(systemAdministrator); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Name,Surname")] SystemAdministrator systemAdministrator) { if (ModelState.IsValid) { db.Entry(systemAdministrator).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(systemAdministrator)); }
public ActionResult Create([Bind(Include = "Id,Name,Surname")] SystemAdministrator systemAdministrator) { if (ModelState.IsValid) { db.SystemAdministrators.Add(systemAdministrator); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(systemAdministrator)); }
protected void SeedEverything(UserDbContext context) { context.Database.EnsureCreated(); // create System admin if not exist var sysAdmin = new SystemAdministrator() { Email = @"*****@*****.**", City = "Admin city", IsVerified = true, LastName = "Admin", Name = "Admin", Password = "******", Phone = "123admin" }; _ = context.Users.FirstOrDefault(u => u.Email == sysAdmin.Email) ?? context.Users.Add(sysAdmin).Entity; var carAdmin = new RentACarAdministrator() { Email = @"*****@*****.**", City = "Car admin city", IsVerified = true, LastName = "Car Admin", Name = "Car Admin", Password = "******", Phone = "123caradmin" }; if (!context.Users.Any(u => u.Email == carAdmin.Email)) { context.Users.Add(carAdmin); } var aviationAdmin = new AviationAdministrator() { Email = @"*****@*****.**", City = "Aviation admin city", IsVerified = true, LastName = "Aviation Admin", Name = "Aviation Admin", Password = "******", Phone = "123aviationadmin" }; if (!context.Users.Any(u => u.Email == aviationAdmin.Email)) { context.Users.Add(aviationAdmin); } context.SaveChanges(); }
// GET: SystemAdministrators/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } SystemAdministrator systemAdministrator = db.SystemAdministrators.Find(id); if (systemAdministrator == null) { return(HttpNotFound()); } return(View(systemAdministrator)); }
public static SystemAdministratorDto ToDto(this SystemAdministrator systemAdministrator) { return(new SystemAdministratorDto { }); }
private void LoginExecute(object obj) { try { person.password = (obj as PasswordBox).Password; tblUser user = Service.Service.GetUser(person.username, person.password); if (user == null) { if (person.username == "WPFMaster" && person.password == "WPFAccess") { Owner owner = new Owner(); login.Close(); owner.Show(); } else { MessageBox.Show("Invalid username or password.Try again"); } } else { if (Service.Service.isAdministrator(user) != null) { tblAdministrator a = Service.Service.isAdministrator(user); if (a.expiryDate < DateTime.Now) { MessageBox.Show("The expiration date of your access has expired. Please conntact the company mannagment"); } else { string type = Service.Service.TypeOfAdmin(a); if (type == "Local") { LocalAdministrator la = new LocalAdministrator(); login.Close(); la.ShowDialog(); } else if (type == "Team") { TeamAdministrator ta = new TeamAdministrator(); ta.ShowDialog(); } else { SystemAdministrator sa = new SystemAdministrator(); login.Close(); sa.ShowDialog(); } } } else if (Service.Service.isEmployee(user) != null) { tblEmployee e = Service.Service.isEmployee(user); Employee employee = new Employee(); employee.Show(); } else if (Service.Service.isManager(user) != null) { tblManager m = Service.Service.isManager(user); if (m.levelOfResponsibility != null) { Manager manager = new Manager(); manager.Show(); } else { MessageBox.Show("Please wait until the Local administrator assigns a level of responsibility"); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void DeleteEntity(SystemAdministrator entity) { systemAdministratorRepository.DeleteEntity(entity); }
public void UpdateEntity(SystemAdministrator entity) { systemAdministratorRepository.UpdateEntity(entity); }
public SystemAdministrator AddEntity(SystemAdministrator entity) { return(systemAdministratorRepository.AddEntity(entity)); }
public SystemAdministrator Update(SystemAdministrator entity) { return(_systemAdministratorDal.Update(entity)); }
public void Delete(SystemAdministrator entity) { _systemAdministratorDal.Delete(entity); }
public SystemAdministrator Add(SystemAdministrator entity) { return(_systemAdministratorDal.Add(entity)); }
public SystemAdministratorViewModel(SystemAdministrator open) { sa = open; sectorList = Service.Service.GetSectorList(); }