Beispiel #1
0
        // GET: Employees
        public ActionResult Index()
        {
            string errorMsg = String.Empty;

            if (TempData.ContainsKey("error"))
            {
                errorMsg = TempData["error"].ToString();
            }

            List <EmployeesModel> employees = new List <EmployeesModel>();
            List <TeamsModel>     teamNames = new List <TeamsModel>();

            try
            {
                employees = _employeesService.GetAllEmployees();
                teamNames = _teamService.GetTeams();
            }
            catch (Exception e)
            {
                TempData["error"] = $"Problems with getting information from database (services). {e.Message}";
                return(RedirectToAction("Index", "Home"));
            }

            EmployeesVm model = new EmployeesVm()
            {
                Employees = employees,
                TeamNames = teamNames,
                ErrorMsg  = errorMsg
            };

            return(View("Index", model));
        }
Beispiel #2
0
        public IActionResult Get()
        {
            var employees = employeesService.GetAllEmployees().Select(s => new Employees {
                EmployeeId = s.EmployeeId,
                FirstName  = s.FirstName,
                LastName   = s.LastName,
                BirthDate  = s.BirthDate,
                Address    = s.Address
            }).ToList();

            return(Ok(employees));
        }
        // GET: Teams
        public ActionResult Index()
        {
            string errorMsg = String.Empty;

            if (TempData.ContainsKey("error"))
            {
                errorMsg = TempData["error"].ToString();
            }
            List <ProjectsModel>  projects           = new List <ProjectsModel>();
            List <WorkItemsModel> workItems          = new List <WorkItemsModel>();
            List <EmployeesModel> employees          = new List <EmployeesModel>();
            Dictionary <int, int> workItemsOnProject = new Dictionary <int, int>();

            try
            {
                projects  = _projectService.GetAllProjects();
                workItems = _workItemsService.GetAllWorkItems();
                employees = _employeeService.GetAllEmployees();

                foreach (var workItem in workItems)
                {
                    foreach (var project in projects)
                    {
                        if (project.Id == workItem.Project_Id)
                        {
                            if (workItemsOnProject.ContainsKey(project.Id))
                            {
                                workItemsOnProject[project.Id] += 1;
                            }
                            else
                            {
                                workItemsOnProject.Add(project.Id, 1);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                TempData["error"] = $"Problems with getting information from database (services). {e.Message}";
                return(RedirectToAction("Index", "Home"));
            }
            ProjectsVm model = new ProjectsVm()
            {
                ProjectList        = projects,
                WorkItemsOnProject = workItemsOnProject,
                Employees          = employees,
                ErrorMsg           = errorMsg
            };

            return(View("Index", model));
        }
Beispiel #4
0
 /// <summary>
 /// Employees page with information for desired employee/s
 /// </summary>
 /// <param name="model">Model with id for specific employee</param>
 /// <returns>View for employees</returns>
 public ActionResult GetEmployees(EmployeesModel model)
 {
     if (model.employeeID.HasValue)
     {
         List <Employee> employees   = new List <Employee>();
         Employee        objEmployee = EmployeesService.GetEmployee(model.employeeID.Value);
         if (objEmployee != null)
         {
             employees.Add(objEmployee);
         }
         model.lstEmployees = employees;
     }
     else
     {
         model.lstEmployees = EmployeesService.GetAllEmployees();
     }
     return(View("Employees", model));
 }
Beispiel #5
0
        public static List <SelectListItem> GetEmployeeList()
        {
            List <EmployeesModel> employees    = new List <EmployeesModel>();
            List <SelectListItem> employeeList = new List <SelectListItem>();

            employees = _employeesService.GetAllEmployees();
            foreach (var employee in employees)
            {
                employeeList.Add(
                    new SelectListItem
                {
                    Text  = employee.Id.ToString(),
                    Value = employee.Id.ToString()
                });
            }

            return(employeeList);
        }
        // GET: api/Category
        public HttpResponseMessage GetAll(HttpRequestMessage request)
        {
            EmployeesService employees = new EmployeesService();

            return(request.CreateResponse(HttpStatusCode.OK, employees.GetAllEmployees()));
        }
 public ActionResult <IEnumerable <Employee> > Get()
 {
     return(EmployeesService.GetAllEmployees().ToList());
 }