public CloseTicketResponse Close(CloseTicketRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using (var trans = transactionFactory.GetTransaction()) { var ticket = repo.Get(request.Identity); if (ReferenceEquals(ticket, null)) { return new CloseTicketResponse { TicketNotFound = true } } ; if (ticket.Closed) { return new CloseTicketResponse { TicketAlreadyClosed = true } } ; ticket.Closed = true; repo.Update(ticket); trans.Commit(); } return(new CloseTicketResponse()); }
public EditTicketResponse Edit(EditTicketRequest request) { logger.Debug("About to validate an edit-ticket request"); var validationResult = ValidateRequest(request); logger.Debug(validationResult); if (!validationResult.IsSuccess) { return(responseCreator.GetResponse(validationResult, null)); } using (var trans = transactionFactory.GetTransaction()) { if (logger.IsDebugEnabled) { logger.Debug($"Transaction used is a {trans.GetType().FullName}"); } var ticket = ticketRepo.Get(request.Identity); editor.Edit(ticket, request); ticketRepo.Update(ticket); trans.Commit(); return(responseCreator.GetResponse(validationResult, ticket)); } }
public AddWorklogResponse AddWorkLog(AddWorkLogRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using (var transaction = transactionFactory.GetTransaction()) { var getWorklogResponse = workLogProvider.GetWorkLog(request); if (getWorklogResponse?.Success != true) { transaction.Rollback(); return(GetFailureResponse(getWorklogResponse)); } getWorklogResponse.Ticket.WorkLogs.Add(getWorklogResponse.WorkLog); transaction.Commit(); return(new AddWorklogResponse { Success = true, TicketId = getWorklogResponse.Ticket.GetIdentity(), }); } }
public IHttpActionResult Post(CreateUserModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } bool exists; using (var tran = transactionCreator.GetTransaction()) { var existingUser = userQuery.Get(model.username); if (existingUser == null) { userCreator.Add(model.username, model.password); exists = false; } else { passwordChanger.ChangePassword(existingUser, model.password); exists = true; } tran.Commit(); } return(Ok(exists? $"The existing user '{model.username}' was updated" : $"The user '{model.username}' was created")); }
public CreateSprintResponse Create(CreateSprintRequest request) { var validationResult = ValidateRequest(request); var response = responseFactory.GetResponse(validationResult); if (!validationResult.IsSuccess) { return(response); } Sprint sprint; using (var trans = transactionFactory.GetTransaction()) { var project = projectGetter.GetCurrentProject(); if (project == null) { response.ProjectDoesNotExist = true; return(response); } sprint = CreateSprint(request, project); sprintRepo.Add(sprint); trans.Commit(); response.Sprint = sprint; } return(response); }
public CreateCommentResponse Create(CreateCommentRequest request) { var validator = validatorFactory.GetValidator(); var validationResult = validator.Validate(request); if (!validationResult.IsSuccess) { return(responseCreator(validationResult, null)); } Comment comment; using (var tran = transactionCreator.GetTransaction()) { var ticket = ticketRepo.Get(request.TicketId); comment = commentFactory.Create(request.Body); ticket.Comments.Add(comment); ticketRepo.Update(ticket); commentRepo.Add(comment); tran.Commit(); } return(responseCreator(validationResult, comment)); }
public CreateProjectResponse CreateNewProject(CreateProjectRequest request) { using (var tran = transactionCreator.GetTransaction()) { var output = wrapped.CreateNewProject(request); tran.Commit(); return(output); } }
public void Create() { using(var tran = transactionCreator.GetTransaction()) { CreateInitialUser(); CreateInitialProject(); tran.Commit(); } }
public Ticket CreateTicket(CreateTicketRequest request) { using (var trans = transactionFactory.GetTransaction()) { var ticket = wrappedInstance.CreateTicket(request); data.Add(ticket); trans.Commit(); logger.InfoFormat("Created ticket {0}: {1}", ticket.GetTicketReference().ToString(true), ticket.Title); return(ticket); } }
public PasswordChangeResponse ChangeOwnPassword(PasswordChangeRequest request) { if (request == null) { throw new ArgumentNullException(nameof(request)); } using (var tran = transactionCreator.GetTransaction()) { var user = userReader.RequireCurrentUser(); if (!IsExistingPasswordCorrect(request.ExistingPassword, user)) { return new PasswordChangeResponse { ExistingPasswordIncorrect = true } } ; if (request.ConfirmNewPassword != request.NewPassword) { return new PasswordChangeResponse { NewPasswordDoesNotMatchConfirmation = true } } ; if (!policy.IsPasswordOk(request.NewPassword, user)) { return new PasswordChangeResponse { NewPasswordDoesNotSatisfyPolicy = true } } ; updater.ChangePassword(user, request.NewPassword); tran.Commit(); } return(new PasswordChangeResponse()); } bool IsExistingPasswordCorrect(string password, User user) { var credentials = new LoginCredentials { Password = password, Username = user.Username, }; return(authService.Authenticate(credentials).Success); }
public DeleteCommentResponse Delete(DeleteCommentRequest request) { var validator = validatorFactory.GetValidator(); var validationResult = validator.Validate(request); if (!validationResult.IsSuccess) { return(responseCreator(validationResult)); } using (var tran = transactionCreator.GetTransaction()) { var comment = data.Get(request.CommentId); comment.Ticket.Comments.Remove(comment); tran.Commit(); } return(responseCreator(validationResult)); }
public EditSprintResponse Edit(EditSprintRequest request) { var validationResult = ValidateRequest(request); if (!validationResult.IsSuccess) { return(responseCreator(validationResult, null)); } Sprint sprint; using (var trans = transactionFactory.GetTransaction()) { sprint = sprintRepo.Get(request.SprintIdentity); mapper.Map(request, sprint); sprintRepo.Update(sprint); trans.Commit(); } return(responseCreator(validationResult, sprint)); }
public EditCommentResponse Edit(EditCommentRequest request) { var validator = validatorFactory.GetValidator(); var validationResult = validator.Validate(request); if (!validationResult.IsSuccess) { return(responseCreator(validationResult)); } using (var tran = transactionCreator.GetTransaction()) { var comment = commentRepo.Get(request.CommentIdentity); comment.Body = request.Body; comment.LastEditTimestamp = environment.GetCurrentUtcTimestamp(); commentRepo.Update(comment); tran.Commit(); } return(responseCreator(validationResult)); }
public void Load() { using (var tran = transactionCreator.GetTransaction()) { var project = repo.Query <Project>().First(); var admin = userQuery.Get(AdminUser.Username); admin.SiteAdministrator = true; var youssef = CreateYoussef(); project.Administrators.Add(youssef); var sprint1 = CreateSprintOne(project); var sprint2 = CreateSprintTwo(project); var sprint3 = CreateSprintThree(project); var bug = CreateBugType(); var enhancement = CreateEnhancementType(); var ticket1 = CreateTicketOne(sprint1, youssef, enhancement); var ticket2 = CreateTicketTwo(sprint1, youssef, enhancement); var ticket3 = CreateTicketThree(sprint1, youssef, enhancement); var ticket4 = CreateClosedTicketFour(sprint1, youssef, bug); var ticket5 = CreateTicketFive(sprint2, youssef, bug); var ticket6 = CreateTicketSix(sprint2, youssef, bug); project.NextAvailableTicketNumber = 7; var comment1 = CreateCommentOne(ticket1, youssef); var comment2 = CreateCommentTwo(ticket2, admin); var comment3 = CreateCommentThree(ticket2, admin); var comment4 = CreateCommentFour(ticket2, admin); CreateExistingLabelOne(ticket2, ticket3, ticket4); CreateExistingLabelTwo(ticket6); tran.Commit(); } }