Esempio n. 1
0
        public async Task <IActionResult> CreateAsync(int projectId, IssueViewModel model)
        {
            model.CanEdit = true;
            var projectResult =
                await projects.GetProjectForEditingAsync <ProjectViewModel>(projectId, User);

            if (projectResult.NotificationType == NotificationType.Error)
            {
                this.AddNotification(projectResult.Message, projectResult.NotificationType);
                return(RedirectToAction("Index", "Projects"));
            }

            await PerformServerValidationsAsync(projectResult.Value, model);

            if (!ModelState.IsValid)
            {
                await GetDropdownValues(projectId);

                return(View(model));
            }

            var result = await issues.CreateIssueAsync(projectId, model, User);

            this.AddNotification(result.Message, result.NotificationType);

            return(RedirectToAction("Edit", "Projects", new { id = projectId }));
        }
        public async Task <IssueDto> CreateIssueAsync(ApplicationUser user, long projectId, string name, string description, CancellationToken cancellationToken = default)
        {
            var issue = await _issuesService.CreateIssueAsync(user, projectId, name, description, cancellationToken);

            return(issue == null ? null : _mapper.Map <IssueDto>(issue));
        }