public ActionResult EditIssue(EditIssueModel model) { if (ModelState.IsValid) { IssueDTO issue = (IssueDTO)model; var result = librarianContext.UpdateIssue(issue); if (result) { TempData["OperationStatus"] = true; TempData["OpearionMessage"] = "Новые данные успешно сохранены"; } else { TempData["OperationStatus"] = false; TempData["OpearionMessage"] = "Произошла ошибка при обновлении данных"; } return(RedirectToAction("Issues", "LibrarianPage")); } else { return(View(model)); } }
public async Task StatusConversation() { using var helper = await new SimpleTestHelperBuilder().Build(); { var user = helper.User; var project = helper.Project; var issue = await helper.Helper.GetIssueAsync(helper.Issue.Id); var uri = $"/api/projects/{project.Id}/issues/{issue.Id}"; var newState = await helper.Helper.GetStateByNameAsync(issue.ProjectId, State.NegotiationState); var issueDTO = new IssueDTO(issue, newState, project, user, user); var response = await helper.client.PutAsync(uri, issueDTO.ToStringContent()); Assert.IsTrue(response.IsSuccessStatusCode); issue = await helper.GetIssueAsync(helper.Issue.Id); var latestConversationItem = issue.ConversationItems.Last(); Assert.AreEqual(latestConversationItem.CreatorUserId, user.Id); Assert.AreEqual(latestConversationItem.Type, IssueConversation.StateChangeType); Assert.AreNotEqual(latestConversationItem.Data, ""); } }
// Helper function to display user with selections. private async Task<DialogTurnResult> DisplaySelections(WaterfallStepContext stepContext) { var context = stepContext.Context; var issueRequestState = await IssueRequestAccessor.GetAsync(context); // Display their request await context.SendActivityAsync($"Creating new issue with title: {issueRequestState.IssueTitle}\r\n" + $"And body: {issueRequestState.IssueBody}\r\nIn the {issueRequestState.RepoName} repo."); // Create and save job string conversationId = await _jobService.StartJob(context); // Post to probot post(conversationId, issueRequestState) // TODO: var obj = new IssueDTO() { conversationId = conversationId, issue = issueRequestState.IssueTitle, }; await _probotService.PostIssue(obj); // clear issueRequestState for the next call await IssueRequestAccessor.SetAsync(stepContext.Context, null); return await stepContext.EndDialogAsync(); }
public async Task <Result> EditIssue(IssueDTO dto, string userId, string userDept) { Result result = new Result(); try { Issues issue = _repo.GetById <Issues>(Convert.ToInt32(dto.Id)); issue.Issue = dto.Issue; issue.SeverityLevel = dto.SeverityLevel; issue.Description = dto.Description; issue.AssignedTo = dto.AssignedTo; issue.Date = dto.Date; issue.Action = dto.Action; issue.Status = dto.Status; issue.ModifiedBy = userId; issue.ModifiedDate = DateTime.UtcNow; _repo.Update(issue); await _repo.SaveAsync(); result.Message = "Issue has been successfully updated."; result.Success = true; } catch (Exception) { throw; } return(result); }
public async Task IssueCanceledMesageTest2() { using var helper = await new SimpleTestHelperBuilderMessage().Build(); var user = helper.User; var project = helper.Project; var issue = await helper.Helper.GetIssueAsync(helper.Issue.Id); var uri = $"/api/projects/{project.Id}/issues/{issue.Id}"; var newState = await helper.Helper.GetStateByNameAsync(issue.ProjectId, State.ReviewState); var issueDTO = new IssueDTO(issue, newState, project, user, user); var response = await helper.client.PutAsync(uri, issueDTO.ToStringContent()); Assert.IsTrue(response.IsSuccessStatusCode); uri = $"/api/messages/{helper.User.Id}"; response = await helper.client.GetAsync(uri); Assert.IsTrue(response.IsSuccessStatusCode); var messageList = await response.Parse <IList <MessageDTO> >(); Assert.AreEqual(0, messageList.Count); }
public async Task <IssueDTO> UpdateIssue(IssueDTO IssueDTO) { try { Issue Issue = this._mapper.Map <Issue>(IssueDTO); Issue.ModifiedOn = DateTime.Now; await this.UpdateAsyn(Issue, Issue.IssueId); return(IssueDTO); } catch (DbEntityValidationException e) { string error = ""; foreach (var eve in e.EntityValidationErrors) { error = string.Format("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", eve.Entry.Entity.GetType().Name, eve.Entry.State); Console.WriteLine(error); foreach (var ve in eve.ValidationErrors) { error += "<br />" + string.Format("- Property: \"{0}\", Error: \"{1}\"", ve.PropertyName, ve.ErrorMessage); } } throw new Exception(error); } catch (Exception ex) { throw new Exception(ex.InnerException == null ? ex.Message : ex.InnerException.Message); } }
public async Task <IssueDTO> CreateChild(IssueDTO issue) { var child = await CreateIssue(issue).Parse <IssueDTO>(); await SetIssueChild(child.Id); return(child); }
public void UpdateIssue(IssueDTO issue) { using (var unitOfWork = UnitOfWorkProvider.Create()) { Repository.Update(Mapper.Map(issue, Repository.GetById(issue.Id))); unitOfWork.Commit(); } }
public void DeleteIssue(IssueDTO issue) { using (var unitOfWork = UnitOfWorkProvider.Create()) { Repository.Delete(Mapper.Map <Issue>(issue)); unitOfWork.Commit(); } }
public override IssueDTO GetIssueDTOCopy(HttpClient client, SimpleTestHelper helper) { IssueDTO issueCopy = base.GetIssueDTOCopy(client, helper); issueCopy.IssueDetail.RequirementsNeeded = false; issueCopy.IssueDetail.Visibility = true; return(issueCopy); }
public override IssueDTO GetIssueDTOCopy(HttpClient client, SimpleTestHelper helper) { IssueDTO issueCopy = base.GetIssueDTOCopy(client, helper); issueCopy.IssueDetail.RequirementsNeeded = false; issueCopy.IssueDetail.StartDate = DateTime.Now.AddSeconds(300); return(issueCopy); }
public IssueDTO Put(IssueDTO issue) { //Need to have error handling! Issue issueToGet = issueRepo.GetById(issue.IssueID); var issueToUpdate = updateIssue(issue, issueToGet); issueRepo.Update(issueToUpdate); return(issue); }
public ActionResult IssueTakeOver(string adminName, int adminId, int issueId) { IssueDTO issue = issueFacade.GetIssueById(issueId); issue.ResponsiblePersonId = adminId; issue.ResponsiblePersonEmail = adminName; issueFacade.UpdateIssue(issue); return(RedirectToAction("Details", new { id = issueId })); }
public async Task <IssueDTO> UpdateAsync(IssueDTO dto) { var model = _mapper.Map <Issue>(dto); _unitOfWork.IssueRepository.UpdateWithIgnoreProperty(model, x => x.StateId); await _unitOfWork.SaveAsync(); return(_mapper.Map <IssueDTO>(model)); }
private async Task <IssueDTO> InitializeModel(IssueDTO IssueDTO, string ticketnumber) { var categories = await tracker.GetAllCategories(); var Products = new List <SelectListItem> { new SelectListItem { Value = "", Text = "Select", Selected = true } }; foreach (var item in categories.Value.ToList()) { Products.Add(new SelectListItem { Value = item.Code, Text = item.CategoryName, Selected = false }); } var Reasons = new List <SelectListItem> { new SelectListItem { Value = "", Text = "Select", Selected = true }, new SelectListItem { Value = "1", Text = "Performance", Selected = false }, new SelectListItem { Value = "2", Text = "Service not working", Selected = false }, new SelectListItem { Value = "3", Text = "Cancellation", Selected = false } }; var Statuses = new List <SelectListItem> { new SelectListItem { Value = "", Text = "Select", Selected = true }, new SelectListItem { Value = "New", Text = "New", Selected = false }, new SelectListItem { Value = "InProgress", Text = "In Progress", Selected = false }, new SelectListItem { Value = "Resolved", Text = "Resolved", Selected = false } }; IssueDTO.Products = Products; IssueDTO.Reasons = Reasons; IssueDTO.TicketNumber = ticketnumber; IssueDTO.Statuses = Statuses; IssueDTO.Status = string.IsNullOrEmpty(IssueDTO.Status) ? "New" : IssueDTO.Status; return(IssueDTO); }
//public void Put(int id) //{ // //Need to have error handling! // Issue issueToGet = issueRepo.GetById(id); // IssueDTO issueDTO = new IssueDTO(issueToGet); // Issue issueToUpdate = updateIssue(issueDTO); // issueRepo.Update(issueToUpdate); //} //private Issue updateIssue(IssueDTO issue) //{ // Issue newIssue = new Issue(); // newIssue.IssueID = issue.IssueID; // newIssue.Title = issue.Title; // newIssue.Description = issue.Description; // newIssue.PublicationDate = issue.PublicationDate; // newIssue.Publisher = issue.Publisher; // newIssue.SeriesNumber = issue.SeriesNumber; // newIssue.IsDeleted = issue.IsDeleted; // //Might need to map more fields to update. // return newIssue; //} private Issue updateIssue(IssueDTO issue, Issue issueToUpdate) { issueToUpdate.Title = issue.Title; issueToUpdate.Description = issue.Description; issueToUpdate.PublicationDate = issue.PublicationDate; issueToUpdate.Publisher = issue.Publisher; issueToUpdate.SeriesNumber = issue.SeriesNumber; issueToUpdate.IsDeleted = issue.IsDeleted; //Might need to map more fields to update. return(issueToUpdate); }
public async Task <ActionResult> Post([FromRoute] ObjectId projectId, [FromBody] IssueDTO dto) { if (dto.Project.Id != default && dto.Project.Id != projectId) { throw new HttpStatusException(400, "Project id must be the same in url and body or not defined in body"); } dto.Project.Id = projectId; var res = await _issueService.Create(dto); return(CreatedAtAction(nameof(Get), new { projectId, id = res.Id }, res)); }
public async Task <ActionResult> Issue(IssueDTO trackerModel) { if (ModelState.IsValid) { await this.tracker.CreateIssue(trackerModel); } trackerModel = await InitializeModel(trackerModel, trackerModel.TicketNumber); ModelState.AddModelError("Success", "Ticket created sucessfully."); return(View(trackerModel)); }
//public void Delete(IssueDTO issue) //{ // //Need to have error handling! // var issueToDelete = issueRepo.GetById(issue.IssueID); // issueRepo.Delete(issueToDelete); //} private Issue convertDTO(IssueDTO issueDto) { Issue newIssue = new Issue(); newIssue.Title = issueDto.Title; newIssue.PublicationDate = issueDto.PublicationDate; newIssue.Publisher = issueDto.Publisher; newIssue.SeriesNumber = issueDto.SeriesNumber; newIssue.Description = issueDto.Description; //newIssue.ComicCreator = issueDto.ComicCreator; return(newIssue); }
public IssuesController(IssueInterface issueRepo) { this.issueRepo = issueRepo; //issueRepo = new IssuesRepo(); //IEnumerable someIssues = issueRepo.GetAll(); newIssues = new List <IssueDTO>(); foreach (Issue i in issueRepo.GetAll()) { IssueDTO newIssue = new IssueDTO(i); newIssues.Add(newIssue); } }
// GET api/issues/id public IssueDTO GetById(int id) { Issue someIssue = issueRepo.GetById(id); if (someIssue == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } IssueDTO someIssueDTO = new IssueDTO(someIssue); return(someIssueDTO); }
public async Task <ActionResult> Edit(IssueDTO trackerModel) { if (ModelState.IsValid) { await this.tracker.UpdateIssue(trackerModel); } var issue = await tracker.GetIssues(trackerModel.IssueId.ToString()); issue.Value = await InitializeModel(issue.Value, issue.Value.TicketNumber); return(View(issue.Value)); }
public Issue Post(IssueDTO issueDto) { if (issueDto == null) { return(null); throw new HttpResponseException(HttpStatusCode.NotAcceptable); } Issue newIssue = convertDTO(issueDto); issueRepo.Add(newIssue); return(newIssue); }
public bool UpdateIssue(IssueDTO issue) { try { GenericRepository <Issues> generic = new GenericRepository <Issues>(_context); Issues db = (Issues)issue; generic.Update(db); return(true); } catch { return(false); } }
public void GetAllIssue() { //Arrange var mockIssueRepo = new Mock <IssueInterface>(); mockIssueRepo.Setup(x => x.GetById(3)).Returns(new Issue { IssueID = 3 }); var controller = new IssuesController(mockIssueRepo.Object); //Act IssueDTO issueDTO = controller.GetById(3); //Assert Assert.AreEqual(3, issueDTO.IssueID); }
public async Task <IssueDTO> CreateAsync(IssueDTO dto) { var vehicle = _mapper.Map <VehicleDTO>(await _unitOfWork.VehicleRepository.GetByIdAsync(dto.Vehicle.Id)); if (IsWarrantyCase(vehicle)) { dto.Warranty = true; } var model = _mapper.Map <Issue>(dto); await _unitOfWork.IssueRepository.AddAsync(model); await _unitOfWork.SaveAsync(); return(_mapper.Map <IssueDTO>(model)); }
// issue is in cancelled state after this test. public async Task CustomerCanceledIssueTestAsync() { using var helper = await new SimpleTestHelperBuilderIssueAuthorization(Role.CustomerRole).Build(); var uri = $"/api/projects/{helper.Project.Id}/issues/{helper.Issue.Id}"; helper.Issue.State = await helper.Helper.GetStateByNameAsync(helper.Project.Id, State.CancelledState); var res = await helper.client.PutAsync(uri, helper.Issue.ToStringContent()); Assert.IsTrue(res.IsSuccessStatusCode); res = await helper.client.GetAsync(uri); IssueDTO updatedIssue = await res.Parse <IssueDTO>(); Assert.AreEqual(updatedIssue.State.Name, State.CancelledState); }
public async Task <ActionResult> Category(IssueDTO trackerModel) { if (ModelState.IsValid) { await this.tracker.CreateIssue(trackerModel); } var Products = new List <SelectListItem> { new SelectListItem { Value = "", Text = "Select", Selected = true }, new SelectListItem { Value = "1", Text = "Internet", Selected = false }, new SelectListItem { Value = "2", Text = "Wireless/Mobile", Selected = false }, new SelectListItem { Value = "3", Text = "BellTV", Selected = false } }; var Reasons = new List <SelectListItem> { new SelectListItem { Value = "", Text = "Select", Selected = true }, new SelectListItem { Value = "1", Text = "Performance", Selected = false }, new SelectListItem { Value = "2", Text = "Service not working", Selected = false }, new SelectListItem { Value = "3", Text = "Cancellation", Selected = false } }; var Issue = new IssueDTO { Products = Products, Reasons = Reasons }; ModelState.AddModelError("Success", "Ticket created sucessfully."); return(View(Issue)); }
// PUT api/<controller>/5 public async Task <IHttpActionResult> Put([FromBody] IssueDTO value) { var lst = await _issueTrackerService.GetIssue(value.IssueId); if (lst == null) { return(BadRequest()); } value.CreatedOn = lst.CreatedOn; value.CreatedBy = lst.CreatedBy; value.ResolvedOn = lst.ResolvedOn; IssueNoteDTO notes = new IssueNoteDTO() { IssueId = value.IssueId, Notes = value.ResolutionDetail, CreatedBy = lst.CreatedBy, CreatedOn = lst.CreatedOn, ModifiedBy = "Test", ModifiedOn = DateTime.Now }; await _notesService.CreateNotes(notes); await _issueTrackerService.UpdateIssue(value); return(Ok(value)); }
public async Task <Result> AddIssue(IssueDTO dto, string userId, string userDept, string userRole) { Result result = new Result(); try { if (userRole == nameof(Role.DPO) || userRole == nameof(Role.ADMINISTRATOR)) { userDept = (await _queryService.GetDocumentById(dto.DocId.ToString())).DepartmentId; } Issues issues = new Issues { CreatedBy = userId, CreatedDate = DateTime.UtcNow, DocId = dto.DocId, DepartmentId = userDept, Issue = dto.Issue, SeverityLevel = dto.SeverityLevel, Description = dto.Description, Date = dto.Date, AssignedTo = dto.AssignedTo, Action = dto.Action, Status = dto.Status }; _repo.Create(issues); await _repo.SaveAsync(); result.Message = "Issue has been successfully added."; result.IsRedirect = false; result.Id = "Issue"; result.Success = true; } catch (Exception) { throw; } return(result); }