public static void GenerateDemoData( IIssueRepository issueRepository, IProjectRepository projectRepository, IAttachmentRepository attachmentRepository) { Project p = new Project("SHOP", "Webshop", "All issues related to the webshop."); projectRepository.Add(p); Issue i = new Issue(p, "Crash after payment", @"I have justed paid for two pairs of shoes - or rather I tried to. When I clicked 'Pay' all I got was a yellow error screen.", 3); issueRepository.Add(i); string errorReport = "This is an error report ..."; Attachment att = new Attachment(i, "Error report", "Error report from end user", Encoding.UTF8.GetBytes(errorReport), "text/plain"); attachmentRepository.Add(att); string logFile = "DEBUG 2014-01-22 15:45:07,610 166033ms [9] Log4NetTraceListener WriteLine - Executing OperationResult OperationResult: type=OK, statusCode=200."; att = new Attachment(i, "Logfile", "Logfile with server stack trace", Encoding.UTF8.GetBytes(logFile), "text/plain"); attachmentRepository.Add(att); i = new Issue(p, "Not calculating VAT correctly", @"When I add both shoes and socks it fails to calculate the VAT correctly.", 3); issueRepository.Add(i); i = new Issue(p, "General Failure?", @"When I press ctrl-P it says 'General failure reading harddisk'! Who is that General and why is he reading my hard disk?", 5); issueRepository.Add(i); }
private void Create(IssueViewModel viewModel) { int userId = HttpContext.Current.User.Identity.GetUserId <int>(); if (!_groupService.IsGroupOwner(viewModel.GroupId, userId)) { throw new ArgumentException("Wrong groupId or group does not belong to you"); } var group = _groupService.Get(viewModel.GroupId); viewModel.IssueNumber = ++group.IssuesTotal; _groupRepository.Update(group); int issueId = _issueRepository.Add(viewModel.ToEntity()); Comment comment = new Comment() { CreatedAt = DateTime.Now, IssueId = issueId, Text = string.IsNullOrWhiteSpace(viewModel.Text)? string.Empty : viewModel.Text, UserId = userId, IsEdited = false }; _commentRepository.Add(comment); }
public async Task <IActionResult> Create([FromBody] IssueViewModel model) { if (model == null) { return(StatusCode(400, "Invalid parameter(s).")); } Issue issue = new Issue { IssueId = model.IssueId, RoomCode = model.RoomCode, CreatedOn = model.CreatedOn, Description = model.Description, Resolved = model.Resolved }; //Insert issue var result = await _issueRepository.Add(issue); if (result == null) { return(StatusCode(500, "A problem occured while saving the issue. Please try again!")); } return(Ok(new IssueViewModel { IssueId = result.IssueId, RoomCode = result.RoomCode, Description = result.Description, CreatedOn = result.CreatedOn, Resolved = result.Resolved })); }
public async Task <bool> Handle(IssueAddNewCommand message, CancellationToken ct) { if (await _issueRepository.GetAsync(message.Id) is { } existingIssueEntity) { if (existingIssueEntity.IsDeleted) { existingIssueEntity.Return(); return(await _issueRepository.UnitOfWork.SaveEntitiesAsync(ct)); } _logger.LogError("Issue with Id {Id} already exist, is not deleted. Existing: {@ExistingIssue}, new: {Message}", message.Id, existingIssueEntity, message); return(false); } var issueEntity = Mapper.Map(message, await _issueRepository.GetStatusAsync(message.StatusId), await _issueRepository.GetPriorityAsync(message.PriorityId)); _issueRepository.Add(issueEntity); if (await _issueRepository.UnitOfWork.SaveEntitiesAsync(ct)) { var issueDTO = Mapper.Map(issueEntity); await _eventPublisher.Publish(new IssueAddedIntegrationEvent(issueDTO), ct); return(true); } else { return(false); } }
private async Task <Issue> CreateIssue() { var issue = new Issue("sa", 1, "1", new IssueState("1")); _issueRepository.Add(issue); await _issueRepository.Commit(); return(issue); }
public ActionResult Create(CreateViewModel vmIssue) { Issue issue = vmIssue; issue.AuthorID = User.Identity.GetUserId(); if (ModelState.IsValid) { _repo.Add(issue); return(RedirectToAction("Index")); } return(View(vmIssue)); }
public async Task <int> Handle(CreateIssueCommand request, CancellationToken cancellationToken) { var userId = _currentUserService.GetUserId(); var defaultState = await _issueStateRepository.GetDefaultState(); var issue = new Issue(request.Summary, request.IssueTypeId, userId, defaultState); _issueRepository.Add(issue); await _issueRepository.Commit(cancellationToken); return(issue.Id); }
public async Task <Guid> Create(IssueDto issueDto) { var issue = await _issueRepository.Get(issueDto.Id); if (issue != null) { throw new Exception($"Issue with {issueDto.Id} already exists."); } issue = new Issue(Guid.NewGuid(), issueDto.Name, issueDto.Description); issue.SetDueDate(issueDto.DueDate); await _issueRepository.Add(issue); return(issue.Id); }
public async Task<bool> Handle(IssueAddCommand message, CancellationToken ct) { if (await _issueRepository.GetAsync(message.Id) is { } existingIssueEntity) { if (existingIssueEntity.IsDeleted) { existingIssueEntity.Return(); return await _issueRepository.UnitOfWork.SaveEntitiesAsync(ct); } _logger.LogError("Issue with Id {Id} already exist, is not deleted. Existing: {@ExistingIssue}, new: {Message}", message.Id, existingIssueEntity, message); return false; } var issueEntity = Mapper.Map(message, await _issueRepository.GetStatusAsync(message.StatusId), await _issueRepository.GetPriorityAsync(message.PriorityId)); _issueRepository.Add(issueEntity); return await _issueRepository.UnitOfWork.SaveEntitiesAsync(ct); }
public IHttpActionResult Post(Issue issue) { _issueRepository.Add(issue); return(Created("http://localhost:50765/issues/" + issue.Id, issue)); }
public Issue Add(Issue issue) { return(_issueRepo.Add(issue)); }