Exemplo n.º 1
0
 public TimeEntryCreationService(IProjectRepository projectRepository, IIssueRepository issueRepository,
                                 IUserRepository userRepository, ITimeEntryActivityRepository timeEntryActivityRepository,
                                 ITimeEntryRepository timeEntryRepository)
 {
     _projectRepository           = projectRepository;
     _issueRepository             = issueRepository;
     _userRepository              = userRepository;
     _timeEntryActivityRepository = timeEntryActivityRepository;
     _timeEntryRepository         = timeEntryRepository;
 }
Exemplo n.º 2
0
        public async Task <IActionResult> Create(
            CancellationToken cancellationToken,
            [FromBody] CreateTimeEntryActivityBinding binding,
            [FromServices] ITimeEntryActivityRepository timeEntryActivityRepository)
        {
            var timeEntryActivity = await timeEntryActivityRepository.Get(binding.Id, cancellationToken);

            if (timeEntryActivity != null)
            {
                if (!timeEntryActivity.Name.Equals(binding.Name))
                {
                    throw new ApiException(HttpStatusCode.Conflict, ErrorCode.TimeEntryActivityAlreadyExists,
                                           "Issue status already exists with other parameters");
                }
            }

            timeEntryActivity = new TimeEntryActivity(binding.Id, binding.Name, binding.IsActive);

            await timeEntryActivityRepository.Save(timeEntryActivity);

            return(CreatedAtRoute("GetTimeEntryActivityAdminRoute", new { id = timeEntryActivity.Id }, null));
        }