public async Task <GetGlobalLimitOperationResponse> Execute()
        {
            var globalLimit = await _limitRepository.GetGlobalAsync();

            return(new GetGlobalLimitOperationResponse
            {
                DaysPerQuarter = globalLimit.DaysPerQuarter,
                TopicsPerDay = globalLimit.TopicsPerDay
            });
        }
Ejemplo n.º 2
0
        private async Task <CreateEmployeeOperationResponse> CreateEmployee(IdentityUser identityUser, CreateEmployeeOperationRequest request)
        {
            var roleTask = _roleRepository
                           .QuerySingleOrDefaultAsync(role => role.Title == request.Role);

            var managerId = (await _employeeRepository.GetByEmailAsync(request.ManagerEmail)).Id;

            var getTeamResponse = await _ensureManagerHasTeamOperation.Execute(new EnsureManagerHasTeamRequest { ManagerId = managerId });

            Role role = await roleTask;

            var employee = new Domain.Entity.LearningCalendar.Employee
            {
                Identity = identityUser,
                Team     = new Domain.Entity.LearningCalendar.Team {
                    Id = getTeamResponse.TeamId
                },
                FirstName = request.FirstName,
                LastName  = request.LastName,
                Image     = new Image
                {
                    Value = request.ImageData
                },
                Role = role ?? new Role
                {
                    Title = request.Role
                }
            };

            var limit = await _limitRepository.GetGlobalAsync();

            limit.Employees.Add(employee);

            try
            {
                await _limitRepository.UpdateAsync(limit);
            }
            catch (DbUpdateException)
            {
                throw new EmailAlreadyUseException();
            }

            return(new CreateEmployeeOperationResponse());
        }