public List <ModelViewUsers> GetAllList() { var NegocioEmpleado = new BusinessEmployee(); var NegocioModulos = new BusinessModuleService(); var usuarios = GetAll(); var empleados = NegocioEmpleado.GetAll(); var modulos = NegocioModulos.GetAll(); var lt = (from a in usuarios join b in empleados on a.UserID equals b.FK_UserID join c in modulos on b.FK_ModuleID equals c.ModuleID select new ModelViewUsers() { UserID = a.UserID, ProfileID = a.ProfileID, UserName = a.UserName, Name = a.Name, Email = a.Email, Status = a.Status, DateCreate = a.DateCreate, DateLastAccess = a.DateLastAccess, DateModification = a.DateModification, EmployyeID = b.EmployeeID, Module = c.ID + " - " + c.Base }).ToList(); return(lt); }
public List <ModelViewUserNotification> GetAllNotificationUsers(string ModuleID, string Name) { var NegocioUsuario = new BusinessUsers(); var NegocioEmpleado = new BusinessEmployee(); var NegocioModulosMabe = new BusinessModuleService(); // var usuarios = NegocioUsuario.GetActives().Where(p=> p.ProfileID == 4); var empleados = NegocioEmpleado.GetAll(); var modulos = new List <EntityModuleService>(); var usuarios = new List <ModelViewUserList>(); if (ModuleID != null) { int[] nums = ModuleID.Split(',').Select(int.Parse).ToArray(); modulos = NegocioModulosMabe.GetAll().Where(p => nums.Contains(p.ModuleID)).ToList(); } else { modulos = NegocioModulosMabe.GetAll(); } if (Name != "") { usuarios = NegocioUsuario.GetActives().Where(p => p.ProfileID == 4 && (p.Name.ToLower().Contains(Name.ToLower()) || p.UserName.Contains(Name))).ToList(); } else { usuarios = NegocioUsuario.GetActives(); } return((from a in usuarios join b in empleados on a.UserID equals b.FK_UserID join c in modulos on b.FK_ModuleID equals c.ModuleID select new ModelViewUserNotification() { UserID = a.UserID, Name = "(" + a.UserName + ")" + " " + b.FirstName + " " + b.LastName + " " + c.ID + " - " + c.Base }).ToList()); }
public List <ModelViewUserNotification> GetAllNotificationUsers(string Employee) { var NegocioUsuario = new BusinessUsers(); var NegocioEmpleado = new BusinessEmployee(); var NegocioModulosMabe = new BusinessModuleService(); var empleados = NegocioEmpleado.GetAll(); var modulos = new List <EntityModuleService>(); var usuarios = new List <ModelViewUserList>(); modulos = NegocioModulosMabe.GetAll(); int[] nums = Employee.Split(',').Select(int.Parse).ToArray(); usuarios = NegocioUsuario.GetActives().Where(p => nums.Contains(p.UserID)).ToList(); return((from a in usuarios join b in empleados on a.UserID equals b.FK_UserID join c in modulos on b.FK_ModuleID equals c.ModuleID select new ModelViewUserNotification() { UserID = a.UserID, Name = "(" + a.UserName + ")" + " " + b.FirstName + " " + b.LastName + " " + c.ID + " - " + c.Base }).ToList()); }
public ModelViewUser Authenticate(ModelViewLogin model) { ModelViewUser result = null; var dataUsuario = new RepositoryUser().GetUserName(model.UserName); if (model.Token != GlobalConfiguration.TokenWEB) { if (model.Token != GlobalConfiguration.TokenMobile) { throw new Exception("TokenInvalid"); } } if (dataUsuario == null) { throw new Exception("UserPasswordInvalid"); } if (dataUsuario.ProfileID == 4 && model.Origin == "WEB") { throw new Exception("NoAccess"); } var x = new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(model.Password); if (dataUsuario.Password != new BusinessCryptoMD5(GlobalConfiguration.CryptoKey).CryptoString(model.Password)) { throw new Exception("UserPasswordInvalid"); } if (!dataUsuario.Status) { throw new Exception("UserInvalid"); } if (dataUsuario.ModuleID != null) { var module = new BusinessModuleService().GetAllBYModule(dataUsuario.ModuleID.Value); result = new ModelViewUser() { UserID = dataUsuario.UserID, Name = dataUsuario.Name, Token = dataUsuario.Token, ProfileID = dataUsuario.ProfileID, ChangePassword = dataUsuario.ChangePassword, Email = dataUsuario.Email, UserName = dataUsuario.UserName, Profile = new RepositoryProfile().Get(dataUsuario.ProfileID).Profile, EmployeeStore = new BusinessEmployee().GetEmployeeStore(dataUsuario.UserID), LatWorkshop = module.LatWorkshop, LongWorkshop = module.LongWorkshop }; } else { result = new ModelViewUser() { UserID = dataUsuario.UserID, Name = dataUsuario.Name, Token = dataUsuario.Token, ProfileID = dataUsuario.ProfileID, ChangePassword = dataUsuario.ChangePassword, Email = dataUsuario.Email, UserName = dataUsuario.UserName, Profile = new RepositoryProfile().Get(dataUsuario.ProfileID).Profile, EmployeeStore = new BusinessEmployee().GetEmployeeStore(dataUsuario.UserID), LatWorkshop = 0, LongWorkshop = 0 }; } return(result); }