public async Task <Domain.Entities.Employee> GetEmployeeData(int userId)
        {
            var user = await _userRepository.GetByUserId(userId);

            if (user == null)
            {
                throw new Exception("No user information found.");
            }

            var location = await _locationRepository.GetLocationById(user.LocationId);

            if (location == null)
            {
                throw new Exception("No location information found.");
            }

            var punches = await _timePunchRepository.GetTimePunchesByUserId(userId);

            if (punches == null)
            {
                throw new Exception($"No time punch found for user {userId}");
            }


            var workHourCalculationResult = _workedHourCalculator.CalculateWorkedWeek(punches, location.LabourSettings, user);

            var employeeData = new Domain.Entities.Employee
            {
                RelatedLocation = location,
                RelatedUser     = user,
                WorkReport      = workHourCalculationResult
            };

            return(employeeData);
        }
        protected override void Handle(RegisterCommand request)
        {
            var employee = new Domain.Entities.Employee(Guid.NewGuid(), request.FirstName, request.LastName, request.IdentityId);

            _dbContext.Employees.Add(employee);

            if (_dbContext.SaveChanges() == 0)
            {
                throw new Exception("Could not register new user");
            }
        }
 private EmployeeDTO ConvertEmployeeToDTO(Domain.Entities.Employee employee)
 {
     return(new EmployeeDTO
     {
         ContractType = _contractTypeFactory.GetContractType(employee),
         Id = employee.Id,
         Name = employee.Name,
         Rol = new RolDTO()
         {
             RoleId = employee.RoleId,
             RoleName = employee.RoleName,
             RoleDescription = employee.RoleDescription,
         }
     });
 }
示例#4
0
        private void DetalheAluguel_Load(object sender, EventArgs e)
        {
            Images = Load_Image();
            Domain.Entities.Car    car    = Load_Car();
            Domain.Entities.Client client = Load_Client();
            if (Rent.idEmployee != 0)
            {
                Domain.Entities.Employee employee = Load_Employee();
                this.employee.Text    = employee.Name;
                this.employee.Visible = true;
                employeeTitle.Visible = true;
            }
            this.client.Text = client.Name;
            email.Text       = client.Email;
            pickUp.Text      = Rent.PickUpDate.ToString("dd/MM/yyyy HH:mm");
            dropOff.Text     = Rent.DropOffDate.ToString("dd/MM/yyyy HH:mm");
            status.Text      = car.Status == true ? "Disponível" : "Indisponível";
            amount.Text      = Rent.Value.ToString("C2", CultureInfo.CurrentCulture);

            if (Rent.PaymentType == Domain.Entities.PaymentTypeEnum.Billet)
            {
                payment.Text = "Boleto";
            }
            else if (Rent.PaymentType == Domain.Entities.PaymentTypeEnum.Card)
            {
                payment.Text = "Cartão";
            }
            else
            {
                payment.Text = "Dinheiro";
            }

            branch.Text = car.Branch;
            model.Text  = car.Model;
            board.Text  = car.Board;
            doors.Text  = car.Doors.ToString();
            board.Text  = car.Board;
            fuel.Text   = car.Fuel;
            color.Text  = car.Color;
            year.Text   = car.Year.ToString();
            if (Images.Any())
            {
                image.Image = Image.FromFile(Servers.path + Images.Select(x => x.Path).FirstOrDefault() + Images.Select(x => x.Name).FirstOrDefault());
            }
        }
示例#5
0
            public async Task <Unit> Handle(CreateEmployeeCommand request, CancellationToken cancellationToken)
            {
                var entity = new Domain.Entities.Employee()
                {
                    Name = request.Name,
                };

                _context.Employees.Add(entity);

                await _context.SaveChangesAsync(cancellationToken);

                await _mediator.Publish(new EmployeeCreated()
                {
                    EmployeeId = entity.Id
                }, cancellationToken);

                return(Unit.Value);
            }
示例#6
0
        private void metroLinkSalvar_Click(object sender, EventArgs e)
        {
            Domain.Entities.Employee Employee = new Domain.Entities.Employee();
            Domain.Entities.User     User     = new Domain.Entities.User();

            Employee.Name = name.Text;
            User.Name     = user.Text;
            User.isAdmin  = true;
            User.Password = password.Text;
            try
            {
                Employee.idUser = _appUser.Insert(User);
                _appEmployee.Insert(Employee);
                MetroMessageBox.Show(this, "Administrador cadastrado", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Question, 100);
                Funcionarios_Load(this, new EventArgs());
            }
            catch
            {
                MetroMessageBox.Show(this, "Erro inesperado. Por favor entre em contato com seu administrador", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Error, 100);
            }
        }