public override bool IsUserInRole(string username, string roleName) { bool outputResult = false; string[] namerole = roleName.Split(','); using (KursovikTP db = new KursovikTP()) { foreach (var rn in namerole) { var user = (from u in db.People where u.Login == username select u).SingleOrDefault(); if (user != null) { var role = (from r in db.Role where r.idRole == user.idRole select r).SingleOrDefault(); if (role.NameRole.Equals(rn)) { outputResult = true; } } } } return(outputResult); }
public override string[] GetRolesForUser(string username) { string[] role = new string[] { }; using (KursovikTP db = new KursovikTP()) { try { // Получаем пользователя var user = (from u in db.People where u.Login == username select u).SingleOrDefault(); if (user != null) { // получаем роль var userRole = (from r in db.Role where r.idRole == user.idRole select r).SingleOrDefault(); if (userRole != null) { role = new string[] { userRole.NameRole }; } } } catch { role = new string[] { }; } } return(role); }
public void editStatus(string Login, string role) { using (KursovikTP db = new KursovikTP()) { var user = (from u in db.People where u.Login == Login select u).SingleOrDefault(); if (role == "Applicant") { var resume = user.Applicant.Resume; foreach (var rm in resume) { rm.Status = 0; } } else if (role == "Employer") { var jobs = user.Employer.Jobs; foreach (var jb in jobs) { jb.Status = 0; } } db.SaveChanges(); } }
public void CheckTime(string Login) { using (KursovikTP db = new KursovikTP()) { var user = (from u in db.People where u.Login == Login select u).SingleOrDefault(); var role = (from r in db.Role where r.idRole == user.idRole select r).SingleOrDefault(); var date = DateTime.Now; if (role.NameRole == "Applicant") { int result = DateTime.Compare(date.Date, user.Applicant.TimeAction.Date); if (result > 0) { user.idRole = 4; editStatus(user.Login, role.NameRole); } } else if (role.NameRole == "Employer") { int result = DateTime.Compare(date.Date, user.Employer.TimeAction.Date); if (result > 0) { user.idRole = 4; editStatus(user.Login, role.NameRole); } } db.SaveChanges(); } }
public override bool ValidateUser(string username, string password) { using (KursovikTP db = new KursovikTP()) { var result = (from u in db.People where (u.Login == username && u.Password == password) select u).SingleOrDefault(); if (result != null) { return(true); } else { return(false); } } }