public ActionResult Admin(int employeeid) { List <MiddlewareViewModel> Middlewareviewmodellist = new List <MiddlewareViewModel>(); List <Middleware> employeemiddlewarelist = MiddlewareService.GetByEmployee(employeeid); using var context = new SqlLiteContext(); List <Middleware> middlewarelist = context.Middlewares.ToList(); foreach (Middleware t in middlewarelist) { MiddlewareViewModel mvm = new MiddlewareViewModel(); mvm.MiddlewareId = t.MiddlewareId; mvm.EmployeeId = employeeid; mvm.Name = t.Name; foreach (Middleware te in employeemiddlewarelist) { if (t.MiddlewareId == te.MiddlewareId) { mvm.Connected = true; } } Middlewareviewmodellist.Add(mvm); } var sortedlist = Middlewareviewmodellist.OrderBy(foo => foo.Name).ToList(); var arv = new BindEmployeeMiddlewareViewModel(sortedlist); return(View(arv)); }
public List <MiddlewareViewModel> GetMiddlewareView(int employee) { List <MiddlewareViewModel> MiddlewareViewModels = new List <MiddlewareViewModel>(); List <Middleware> targetData = MiddlewareService.GetByEmployee(employee); if (targetData == null) { return(MiddlewareViewModels); } foreach (Middleware target in targetData) { MiddlewareViewModel evm = new MiddlewareViewModel { MiddlewareId = target.MiddlewareId, Name = target.Name }; MiddlewareViewModels.Add(evm); } return(MiddlewareViewModels); }