public async Task <IActionResult> AddBug(int projectId, BugInputModel inputModel)
        {
            if (!this.IsCurrentUserInProject(projectId))
            {
                return(Unauthorized());
            }

            if (!ModelState.IsValid)
            {
                inputModel.UserStoryDropDown = await this.userStoryService.GetUserStoryDropDownsAsync(projectId);

                inputModel.SeverityDropDown = await this.bugsService.GetSeverityDropDown();

                return(View(inputModel));
            }

            try
            {
                var inputDto = this.mapper.Map <BugInputModelDto>(inputModel);
                await this.bugsService.CreateBugAsync(projectId, inputDto);

                return(RedirectToAction(nameof(GetAll), new { projectId = projectId }));
            }
            catch
            {
                return(RedirectToAction("Error", "Error"));
            }
        }
        public async Task <IActionResult> AddBug(int projectId, int userStoryId)
        {
            var inputModel = new BugInputModel()
            {
                UserStoryId       = userStoryId,
                UserStoryDropDown = await this.userStoryService.GetUserStoryDropDownsAsync(projectId),
                SeverityDropDown  = await this.bugsService.GetSeverityDropDown(),
            };

            return(View(inputModel));
        }
        public IHttpActionResult PostBug(BugInputModel bugInput)
        {
            if (bugInput == null)
            {
                return BadRequest("Missing bug data.");
            }

            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            var currentUserId = User.Identity.GetUserId();

            var bug = new Bug()
            {
                Title = bugInput.Title,
                Description = bugInput.Description,
                Status = BugStatus.Open,
                Date = DateTime.Now,
                UserId = currentUserId
            };

            this.Data.Bugs.Add(bug);
            this.Data.SaveChanges();

            if (currentUserId == null)
            {
                return CreatedAtRoute("DefaultApi",
                    new { id = bug.Id },
                    new { bug.Id, Message = "Anonymous bug submitted." });
            }

            return CreatedAtRoute("DefaultApi",
                new { id = bug.Id },
                new { bug.Id, Author = User.Identity.GetUserName(), Message = "User bug submitted." });
        }