public void Register(EmployeeViewModel employeeViewModel)
        {
            var domain = _mapper.Map <Employee>(employeeViewModel);

            domain.JobTitle = _jobTitleRepository.GetById(new Guid("C1EBE077-C5B0-49F5-3FE3-08D55DCDFB1D"));

            _employeeRepository.Add(domain);
            _employeeRepository.SaveChanges();
        }
        public RequestProcessDTO GetRequestDataById(string id)
        {
            var vacation = _vacations.GetById(id);

            if (vacation != null)
            {
                var    employee     = _employees.GetById(vacation.EmployeeID);
                var    vacationType = _vacationTypes.GetById(vacation.VacationTypeID).VacationTypeName;
                var    jobTitle     = _jobTitles.GetById(employee.JobTitleID).JobTitleName;
                var    status       = _vacationStatusTypes.GetById(vacation.VacationStatusTypeID).VacationStatusName;
                string processedBy  = null;

                if (vacation.ProcessedByID != null)
                {
                    var processedByTemp = _employees.GetById(vacation.ProcessedByID);
                    processedBy = string.Format($"{processedByTemp.Name} {processedByTemp.Surname}");
                }

                var request = new RequestProcessDTO
                {
                    EmployeeID       = employee.EmployeeID,
                    VacationID       = vacation.VacationID,
                    Comment          = vacation.Comment,
                    DateOfBegin      = vacation.DateOfBegin,
                    DateOfEnd        = vacation.DateOfEnd,
                    Duration         = vacation.Duration,
                    EmployeeName     = string.Format($"{employee.Name} {employee.Surname}"),
                    JobTitle         = jobTitle,
                    Status           = status,
                    VacationType     = vacationType,
                    TeamLeadName     = employee.EmployeesTeam.Count.Equals(0) ? Empty : _employees.GetById(employee.EmployeesTeam.First().TeamLeadID).Name,
                    TeamName         = employee.EmployeesTeam.Count.Equals(0) ? Empty : employee.EmployeesTeam.First().TeamName,
                    ProcessedBy      = processedBy,
                    EmployeesBalance = employee.VacationBalance
                };

                return(request);
            }
            else
            {
                return(new RequestProcessDTO());
            }
        }
        public ProfileDTO GetUserData(string id)
        {
            var employee   = _employees.GetById(id);
            var teamLeader = empty;
            var jobTitle   = _jobTitles.GetById(employee.JobTitleID).JobTitleName;

            if (employee.EmployeesTeam.Count > 0)
            {
                var tempLead = _employees.GetById(employee.EmployeesTeam.First().TeamLeadID);
                teamLeader = string.Format($"{tempLead.Name} {tempLead.Surname}");
            }
            if (employee != null)
            {
                var userData = Mapper.Map <Employee, ProfileDTO>(employee);
                userData.TeamName   = employee.EmployeesTeam.Count.Equals(0) ? empty : employee.EmployeesTeam.First().TeamName;
                userData.TeamLeader = teamLeader;
                userData.JobTitle   = jobTitle;
                userData.EmployeeID = employee.EmployeeID;
                return(userData);
            }

            return(null);
        }
Beispiel #4
0
        public RequestForEmployeeDTO GetEmployeeDataForRequestByID(string id)
        {
            var employee = _employees.GetById(id);

            if (employee != null)
            {
                var jobTitle = _jobTitles.GetById(employee.JobTitleID).JobTitleName;

                var request = new RequestForEmployeeDTO
                {
                    EmployeeID   = employee.EmployeeID,
                    EmployeeName = string.Format($"{employee.Name} {employee.Surname}"),
                    JobTitle     = jobTitle,
                    TeamLeadName = employee.EmployeesTeam.Count.Equals(0) ? Empty : _employees.GetById(employee.EmployeesTeam.First().TeamLeadID).Name,
                    TeamName     = employee.EmployeesTeam.Count.Equals(0) ? Empty : employee.EmployeesTeam.First().TeamName,
                };

                return(request);
            }
            else
            {
                return(new RequestForEmployeeDTO());
            }
        }
Beispiel #5
0
 public JobTitleDTO GetJobTitleById(string id)
 {
     return Mapper.Map<JobTitle,JobTitleDTO>(_jobTitles.GetById(id));
 }
Beispiel #6
0
 public JobTitleViewModel GetById(Guid id)
 {
     return(_mapper.Map <JobTitleViewModel>(_jobTitleRepository.GetById(id)));
 }