예제 #1
0
        public HttpResponseMessage <IEnumerable <BugDTO> > Post(BugDTO dto, string comments)
        {
            Bug bug;

            if (dto.Id != 0)
            {
                bug = _bugsRepository.Get(dto.Id);
                if (bug == null)
                {
                    throw new HttpResponseException(HttpStatusCode.NotFound);
                }
                bug.Approve();
                return(new HttpResponseMessage <IEnumerable <BugDTO> >(GetBacklogBugDtos()));
            }

            bug = Mapper.Map <BugDTO, Bug>(dto);
            bug.Approve();

            _bugsRepository.Add(bug);

            var response = new HttpResponseMessage <IEnumerable <BugDTO> >(GetBacklogBugDtos(), HttpStatusCode.Created);

            //i still don't like this because it's fragmenting management of my links
            response.Headers.Location = new Uri(HostUriFromRequest(Request), bug.Id.ToString());

            return(response);
        }
예제 #2
0
        public HttpResponseMessage Post(BugDTO dto, string comments = null)
        {
            Bug bug;

            if (dto.Id != 0)
            {
                bug = _bugsRepository.Get(dto.Id);
                if (bug == null)
                {
                    return(new HttpResponseMessage(HttpStatusCode.NotFound));
                }
                bug.Approve();
                return(Request.CreateResponse(HttpStatusCode.OK, BugModel.Collection(GetBacklogBugDtos())));
            }

            bug = Mapper.Map <BugDTO, Bug>(dto);
            bug.Approve();

            _bugsRepository.Add(bug);

            var response = Request.CreateResponse(HttpStatusCode.Created, BugModel.Collection(GetBacklogBugDtos()));

            //i still don't like this because it's fragmenting management of my links
            response.Headers.Location = new Uri(HostUriFromRequest(Request), bug.Id.ToString(CultureInfo.InvariantCulture));

            return(response);
        }
예제 #3
0
        public IActionResult AddBug([FromBody] Bug form)
        {
            Error error = new Error();

            form.DateCreated = DateTime.Now;
            if (string.IsNullOrEmpty(form.Severity))
            {
                error.ErrorCode = ErrorCode.INVALID;
                error.Message   = "Select the severity of the bug.";
            }
            else if (string.IsNullOrEmpty(form.Description))
            {
                error.ErrorCode = ErrorCode.INVALID;
                error.Message   = "Please provide the description of the bug.";
            }

            if (error.ErrorCode != ErrorCode.OKAY)
            {
                return(BadRequest(error.Message));
            }

            _bugRepository.Add(form);

            return(GetBugs());
        }
예제 #4
0
        public async Task <IActionResult> AddBug(AddNewBug newbug)
        {
            if (ModelState.IsValid)
            {
                var currentUserId = userManager.GetUserId(HttpContext.User);
                var currentUser   = await userManager.FindByIdAsync(currentUserId);

                var claims = await userManager.GetClaimsAsync(currentUser);

                GlobalVar.globalCurrentUserClaims = claims.ToList();

                var UserIsMangerLevel = UserClaimsLevel.IsManager(claims.ToList(), newbug.NewBugAttributes.AssociatedProject);

                if (UserIsMangerLevel && newbug.NewBugAttributes.AssigneeUserId != null)
                {
                    var assignedUser = await userManager.FindByIdAsync(newbug.NewBugAttributes.AssigneeUserId);

                    newbug.NewBugAttributes.AssingeeUserName = assignedUser.UserName;
                }

                newbug.NewBugAttributes.ReporterID       = userManager.GetUserId(HttpContext.User);
                newbug.NewBugAttributes.ReporterUserName = userManager.GetUserName(HttpContext.User);
                newbug.NewBugAttributes.EnteredDate      = DateTime.Now;

                var bug = _bugRepository.Add(newbug.NewBugAttributes);

                if (bug.Title == null)
                {
                    bug.Title = $"bug{bug.BugId}";
                    bug       = _bugRepository.Update(bug);
                }


                var projectBug = new ProjectBugs
                {
                    BugId     = bug.BugId,
                    ProjectId = bug.AssociatedProject
                };
                _projectRepository.AddProjectBugs(projectBug);


                List <ScreenShots> uniqueFileNames = new List <ScreenShots>();
                if (GlobalVar.InitialScreenShots == true)
                {
                    uniqueFileNames = await UploadScreenShotsToStorage(bug.BugId);
                }

                GlobalVar.InitialScreenShots = false;
                _bugRepository.AddScreenShots(uniqueFileNames);
                return(RedirectToAction("BugDetails", new { bugId = bug.BugId }));
            }
            return(View());
        }
예제 #5
0
        public void Add(BugModel model)
        {
            var appDbEntity = _appRepository.Get(model.Version);

            model.App = AppFactory.Create(appDbEntity);

            var entity = BugFactory.Create(model);

            entity.App = appDbEntity;

            _bugRepository.Add(entity);

            model.Id = entity.Id;
        }
예제 #6
0
        public void AddNewBug(int assignedUserId, int projectId, string subject, int number, byte statusId, byte priorityId, string description)
        {
            var bugFormViewModel = new BugFormViewModel()
            {
                AssignedUserID   = assignedUserId,
                ProjectID        = projectId,
                Subject          = subject,
                Number           = number,
                StatusID         = statusId,
                PriorityID       = priorityId,
                Description      = description,
                CreationDate     = DateTime.Now,
                ModificationDate = DateTime.Now
            };
            var bug = _mapper.Map <BugFormViewModel, Bug>(bugFormViewModel);

            _bugRepository.Add(bug);
            _bugRepository.Save();
        }