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()); }
List <TheoreticalRelationship> GetAddedRelationships(IIdentity <Ticket> editedTicketIdentity, IEnumerable <AddRelationshipRequest> added) { if (added == null || !added.Any()) { return(new List <TheoreticalRelationship>()); } return(added .Where(x => !ReferenceEquals(x.RelationshipId, null)) .Select(add => new { relatedTicket = ticketProvider.GetTicketByReference(add.RelatedTicketReference), relatedIsPrimary = add.ParticipationType == RelationshipParticipant.Secondary, relationshipType = data.Get(add.RelationshipId) }) .Where(x => x.relatedTicket != null) .Select(x => { logger.Debug($"{nameof(GetAddedRelationships)} found added relationship {x.relationshipType}"); return new TheoreticalRelationship { Relationship = x.relationshipType, PrimaryTicket = x.relatedIsPrimary? x.relatedTicket.GetIdentity() : editedTicketIdentity, SecondaryTicket = x.relatedIsPrimary ? editedTicketIdentity : x.relatedTicket.GetIdentity(), Type = TheoreticalRelationshipType.Added, }; }) .ToList()); }
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 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 TEntity Resolve(object source, object destination, IIdentity <TEntity> sourceMember, TEntity destMember, ResolutionContext context) { return((sourceMember != null) ? repo.Get(sourceMember) : null); }
public Comment Read(IIdentity <Comment> id) { if (ReferenceEquals(id, null)) { return(null); } return(commentRepo.Get(id)); }
public LoginStateModel GetLoginState() { var userInfo = userReader.GetCurrentUserInfo(); var user = (userInfo?.Identity != null) ? data.Get(userInfo.Identity) : null; return(new LoginStateModel { UserInfo = userInfo, IsSiteAdmin = user?.SiteAdministrator == true, }); }
public TEntity Resolve(object source, object destination, long sourceMember, TEntity destMember, ResolutionContext context) { var identity = Identity.Create <TEntity>(sourceMember); if (ReferenceEquals(identity, null)) { return(null); } return(repo.Get(identity)); }
public AppCapability GetCapabilities(IIdentity <User> userIdentity, IIdentity <AgiilApp> targetEntity) { if (userIdentity == null) { throw new ArgumentNullException(nameof(userIdentity)); } var user = data.Get(userIdentity); if (user.SiteAdministrator) { return(AppCapability.CreateProject); } return(default);
public EditProjectResponse EditProject(EditProjectRequest request) { var project = data.Get(request.Identity); if (project == null) { throw new ArgumentException($"The project {request.Identity} does not exist.", nameof(request)); } mapper.Map(request, project); var response = responseFactory(); response.Project = project; return(response); }
protected override RuleOutcome GetValueOutcome(IIdentity <TEntity> value) { if (ReferenceEquals(value, null)) { return(Success); } var entity = repository.Get(value); if (ReferenceEquals(entity, null)) { return(Failure); } return(Success); }
public Project GetCurrentProject() { if (session.TryGet(SessionKey.CurrentProjectIdentity, out IIdentity <Project> id)) { return(data.Get(id)); } var project = wrapped.GetCurrentProject(); if (project != null) { session.Set(SessionKey.CurrentProjectIdentity, project.GetIdentity()); } return(project); }
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 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 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 TicketReference GetTicketReference(IIdentity <Ticket> ticketId) => data.Get(ticketId)?.GetTicketReference();
protected User GetUser(ICurrentUserInfo userInfo) { return(query.Get(userInfo.Identity)); }