Ejemplo n.º 1
0
        // GET: Assigments
        public IActionResult Index()
        {
            List <AssignmentViewModel> AssignmentViewModels = new List <AssignmentViewModel>();
            List <Assigment>           targetData           = AssignmentService.GetEvery();

            if (targetData != null)
            {
                foreach (Assigment target in targetData)
                {
                    Employee            employee = EmployeeService.Get(target.Employeeid);
                    AssignmentViewModel avm      = new AssignmentViewModel
                    {
                        Id          = target.Id,
                        Employee    = employee,
                        Beskrivning = target.Beskrivning,
                        Roll        = target.Roll,
                        Teknik      = target.Teknik,
                        Tid         = target.Tid,
                        Uppdrag     = target.Uppdrag,
                        Focus       = target.Focus
                    };
                    if (employee == null)
                    {
                        Employee temp = new Employee();
                        temp.EmployeeId   = 0;
                        temp.EmployeeName = "INTE KOPPLAD TILL NÅGON ANSTÄLLD";
                        avm.Employee      = temp;
                    }
                    AssignmentViewModels.Add(avm);
                }
            }
            var sortedlist = AssignmentViewModels.OrderBy(foo => foo.Employee.EmployeeName).ToList();

            return(View(sortedlist));
        }