public TicketCategory GetByName(string name) { TicketCategory ticketCategory = _dBtsics.TicketCategory .FirstOrDefault(q => q.Name == name); return(ticketCategory); }
private static bool ValidateTicketCategory(TicketCategory tct) { try { bool ValidTicket = true; StringBuilder sb = new StringBuilder(); if (tct.TicketCategoryName == string.Empty) { sb.AppendLine("TicketCategory Name Should be Provided.."); ValidTicket = false; } else if (!Regex.IsMatch(tct.TicketCategoryName, @"[A-Z][a-z]+")) { sb.AppendLine("TicketCategoryName Should Start with Capital Letters.."); ValidTicket = false; } if (ValidTicket == false) { throw new TicketCategoryException(sb.ToString()); } return ValidTicket; } catch(TicketCategoryException ex) { throw ex; } }
public ActionResult Update(TicketCategory ticketCategory) { ApiResult <TicketCategory> apiResult; if (ModelState.IsValid) { if (ticketCategory.Id > 0) { apiResult = TryExecute(() => { _ticketCategoryRepository.Update(ticketCategory); _unitOfWork.Commit(); return(ticketCategory); }, "Ticket Category updated sucessfully"); } else { apiResult = TryExecute(() => { _ticketCategoryRepository.Create(ticketCategory); _unitOfWork.Commit(); return(ticketCategory); }, "Ticket Category created sucessfully"); } } else { apiResult = ApiResultFromModelErrors <TicketCategory>(); } return(Json(apiResult, JsonRequestBehavior.AllowGet)); }
public IHttpActionResult PutTicketCategory(int id, TicketCategory ticketCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != ticketCategory.CategoryID) { return(BadRequest()); } db.Entry(ticketCategory).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!TicketCategoryExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
public void Register(RegisterTicketCommand command) { command.Validate(); if (AddNotifications(command)) { return; } TicketCategory category = _categoryRepository.GetById(command.CategoryId); LedgerIdentityUser user = _identityResolver.GetUser(); if (NotifyNullCategory(category)) { return; } Ticket ticket = _factory.OpenTicket(command.Title, command.Details, command.CategoryId, user.Id); _ticketRepository.Register(ticket); if (Commit()) { PublishLocal(new TicketRegisteredEvent(ticket.Id, ticket.Title, ticket.Details)); } }
public PeriodTicketDetails(TicketCategory category, int validTime, string from, string to) { _validTime = validTime; _from = from; _to = to; _category = category; }
public async Task<IActionResult> Edit(int id, [Bind("Id,Name,NotifyEmail,Status")] TicketCategory ticketCategory) { if (id != ticketCategory.Id) { return NotFound(); } if (ModelState.IsValid) { try { _context.Update(ticketCategory); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TicketCategoryExists(ticketCategory.Id)) { return NotFound(); } else { throw; } } return RedirectToAction(nameof(Index)); } return View(ticketCategory); }
public Task Handle(TicketCategoryUpdatedEvent @event) { var updatedTicketCategory = new TicketCategory { Id = @event.TicketCategory.Id, PriorityCoefficient = @event.TicketCategory.PriorityCoefficient, Name = @event.TicketCategory.Name }; _unitOfWork.TicketCategories.UpdateTicketCategory(updatedTicketCategory); var selectedQueue = _unitOfWork.EmpireQueues.Find(eq => eq.TicketCategoryId == @event.TicketCategory.Id).SingleOrDefault(); if (selectedQueue == null) { return(Task.CompletedTask); } selectedQueue.QueueWeight = @event.TicketCategory.PriorityCoefficient; selectedQueue.Name = @event.TicketCategory.Name; _unitOfWork.EmpireQueues.UpdateQueue(selectedQueue); UpdateEmpireQueueCommand updateEmpireQueueCommand = new UpdateEmpireQueueCommand(selectedQueue); _unitOfWork.SourceEvent(updateEmpireQueueCommand); return(Task.CompletedTask); }
public void Update_Tc(TicketCategory x) { var obj = new List <TicketCategory>(); try { Entities1 entity = new Entities1(); obj = (from t in entity.TicketCategories where t.TicketCategoryId == x.TicketCategoryId select t).ToList(); obj[0].TicketCategoryId = x.TicketCategoryId; obj[0].TicketCategoryName = x.TicketCategoryName; obj[0].TicketDescription = x.TicketDescription; entity.SaveChanges(); } catch (Exception e) { throw (e); } }
public int Add_Tc(TicketCategory s) { try { Entities1 entity = new Entities1(); Entities1 ent = new Entities1(); TicketCategory ticketcat = new TicketCategory(); Id data = new Id(); ticketcat.TicketCategoryName = s.TicketCategoryName; ticketcat.TicketDescription = s.TicketDescription; var val = (entity.Ids.OrderByDescending(u => u.idd).FirstOrDefault()); ticketcat.TicketCategoryId = val.idd; data.name = ""; ent.Ids.Add(data); entity.TicketCategories.Add(ticketcat); ent.SaveChanges(); entity.SaveChanges(); } catch (Exception e) { throw (e); } return(1); }
public void ShouldGetById() { PopulateRepository(); TicketCategory category = appService.GetById(idOne); Assert.AreEqual("Problemas de ativação", category.Name); }
public TicketTests() { Guid userId = Guid.NewGuid(); category = new TicketCategory("Problemas de ativação"); user = new LedgerIdentityUser(userId); ticket = new Ticket("Não consigo anexar documentos", "Meus documentos falham ao serem anexados para enviar e ativar a conta", category.Id, user.Id); }
/// <summary> /// Cancels given TicketOrder in separate transaction /// </summary> /// <param name="ticketOrder"></param> /// <param name="context"></param> public static void CancelOrder(TicketOrder ticketOrder, ApplicationDbContext context) { string projectName = ""; using (DbContextTransaction transaction = context.Database.BeginTransaction()) { context.Entry(ticketOrder).Collection(to => to.TicketCategoryOrders).Load(); foreach (TicketCategoryOrder ticketCategoryOrder in ticketOrder.TicketCategoryOrders) { TicketCategory ticketCategory = context.TicketCategories.Single(tc => tc.TicketCategoryID == ticketCategoryOrder.TicketCategoryID); if (projectName != "") { context.Entry(ticketCategory).Reference(tc => tc.Project).Load(); projectName = ticketCategory.Project.Name; } bool success = false; for (int i = 0; i < 15; i++) { ticketCategory.Ordered -= ticketCategoryOrder.Count; try { context.SaveChanges(); success = true; break; } catch (DbUpdateConcurrencyException ex) { ex.Entries.Single().Reload(); ticketCategory = (TicketCategory)ex.Entries.Single().Entity; continue; } } if (success) { ticketCategoryOrder.Canceled = true; } else { transaction.Rollback(); return; } } ticketOrder.Canceled = true; context.SaveChanges(); transaction.Commit(); } SendCanceledEmail(ticketOrder, projectName); return; }
private OperationResult <TicketCategoryDto> UpdateTicketCategory(TicketCategory domain, TicketCategoryDto ticketCategory) { domain = Mapper.Map(ticketCategory, domain); var result = _repository.Update(domain); _repository.Save(); return(OperationResult.Success(Mapper.Map <TicketCategoryDto>(result))); }
public void TestTicketCategory() { Guid idOne = new Guid("3fe0fcc8-b00d-40ec-ac18-cbeb769ff216"); TicketCategory ticketCategory = new TicketCategory(idOne, "Problemas de ativação"); Assert.AreEqual(idOne, ticketCategory.Id); Assert.AreEqual("Problemas de ativação", ticketCategory.Name); }
public static Ticket CreateTicket(TicketCategory category) { Random rnd = new Random(); Ticket ticket = new Ticket { TicketCategory = category }; return(ticket); }
private bool NotifyNullCategory(TicketCategory category) { if (category == null) { AddNotification("Id inválido", "A Categoria do Ticket não pôde ser encontrada."); return(true); } return(false); }
public async Task<IActionResult> Create([Bind("Id,Name,NotifyEmail,Status")] TicketCategory ticketCategory) { if (ModelState.IsValid) { _context.Add(ticketCategory); await _context.SaveChangesAsync(); return RedirectToAction(nameof(Index)); } return View(ticketCategory); }
public TicketCategory Add(TicketCategory category) { using (var context = new PunchClockDbContext()) { context.TicketCategories.Add(category); context.SaveChanges(); category = context.TicketCategories.Include(x => x.TicketProject).FirstOrDefault(x => x.Id == category.Id);; } return(category); }
public IHttpActionResult GetTicketCategory(int id) { TicketCategory ticketCategory = db.TicketCategories.Find(id); if (ticketCategory == null) { return(NotFound()); } return(Ok(ticketCategory)); }
public ActionResult Create(TicketCategory category) { if (ModelState.IsValid) { _ticketCategoryDao.Create(category); return(RedirectToAction("Index", "TicketCategory")); } ViewBag.categories = _ticketCategoryDao.GetAll().ToList(); return(View("Index")); }
private void tBook_Click(object sender, RoutedEventArgs e) { int index = 0, index_1 = 0; Entities1 entity = new Entities1(); try { Ticket t = new Ticket(); if (txttid.Text != "" && txttcat.SelectedIndex >= 0 && cbmaname.Text != "") { try { TicketCategory tc = new TicketCategory(); t.TicketCategoryId = txttcat.SelectedIndex; t.MatchId = int.Parse(cbmaname.Text); t.NumberOfTickets = txttid.Text; int x = txttcat.SelectedIndex; //MessageBox.Show(x.ToString()); txttpice.Text = ((x + 1) * 1000 * int.Parse(txttid.Text)).ToString(); t.Price = int.Parse(txttpice.Text); //txtcnt.Text = (int.Parse(txtcnt.Text)-int.Parse(txttid.Text)).ToString(); CUSTOMER_BLL obj = new CUSTOMER_BLL(); obj.insert_Customer_Ticket(t); //int[,] count = new int[10, 10]; index = txttcat.SelectedIndex; index_1 = int.Parse(cbmaname.Text); //MessageBox.Show((count[index + 1, index_1] - int.Parse(txttid.Text)).ToString()); count[index + 1, index_1] = count[index + 1, index_1] - int.Parse(txttid.Text); txtcnt.Text = (count[index + 1, index_1]).ToString(); pview.IsEnabled = true; MessageBoxResult result = MessageBox.Show(this, "Ticket Booked Successfully", "Information", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBoxResult result = MessageBox.Show(this, "All Fields are Required", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } } } catch (Exception ex) { MessageBoxResult result = MessageBox.Show(this, "" + ex.Message + "", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); } }
public void CreateCategoryTest() { TicketCategory temp = NewCategory(); HelpdeskService.CreateCategory(temp); Trace.WriteLine(temp.TicketCategoryId); Assert.IsTrue(SelectCategoryById(temp.TicketCategoryId) != null, "The internal selection query used to verify this test failed to return the a row."); Assert.IsTrue(temp.TicketCategoryId > 0, "The returned Id from the CreateQueue test did not return a value greater than 0."); }
/// <summary> /// Creates shiny new queues that are not referenced / altered by other methods. /// </summary> /// <returns></returns> private TicketCategory NewCategory() { TicketCategory expected = new TicketCategory(); expected.Name = "Category Name"; expected.Description = "This is my description of my category"; expected.IsActive = true; expected.QueueId = 1; return(expected); }
public IHttpActionResult PostTicketCategory(TicketCategory ticketCategory) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.TicketCategories.Add(ticketCategory); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = ticketCategory.CategoryID }, ticketCategory)); }
public void ShouldMatchUsingIdSpecification() { TicketCategory ticketCategory = new TicketCategory(idOne, "Problemas com o Login"); TicketCategoryIdSpecification specificationOne = new TicketCategoryIdSpecification(idOne); TicketCategoryIdSpecification specificationTwo = new TicketCategoryIdSpecification(idTwo); bool resultTrue = specificationOne.IsSatisfiedBy(ticketCategory); bool resultFalse = specificationTwo.IsSatisfiedBy(ticketCategory); Assert.IsTrue(resultTrue); Assert.IsFalse(resultFalse); }
public HttpResponseMessage updateSettingCate(int id, [FromUri] TicketCategory cate) { if (ticketService.isCategoryExisted(cate)) { return(Request.CreateResponse(HttpStatusCode.PreconditionFailed, new { msg = "This Category was existed" })); } else { TicketCategory instance = ticketService.updateCategory(cate); return(Request.CreateResponse(HttpStatusCode.OK, instance)); } }
public Task Handle(TicketCategoryUpdatedEvent @event) { var updatedTicketCategory = new TicketCategory { Id = @event.TicketCategory.Id, Name = @event.TicketCategory.Name, PriorityCoefficient = @event.TicketCategory.PriorityCoefficient, }; _unitOfWork.TicketCategories.UpdateTicketCategory(updatedTicketCategory); _hub.Clients.All.SendAsync("ticket-category-updated-event", updatedTicketCategory); return(Task.CompletedTask); }
protected override async Task Handle(SaveEventTicketCommand command) { var eventData = new TicketCategory { Name = command.Name, ModifiedBy = command.ModifiedBy, CreatedUtc = DateTime.UtcNow, IsEnabled = command.IsEnabled }; _ticketRepository.Save(eventData); return; }
public IHttpActionResult DeleteTicketCategory(int id) { TicketCategory ticketCategory = db.TicketCategories.Find(id); if (ticketCategory == null) { return(NotFound()); } db.TicketCategories.Remove(ticketCategory); db.SaveChanges(); return(Ok(ticketCategory)); }
/// <summary> /// Helper method to insert values into the database. If successful, it will set the appropriate row id. /// </summary> /// <param name="Category"></param> private void InsertCategoryIntoDatabase(TicketCategory category) { HelpdeskService.CreateCategory(category); }
/// <summary> /// Creates shiny new queues that are not referenced / altered by other methods. /// </summary> /// <returns></returns> private TicketCategory NewCategory() { TicketCategory expected = new TicketCategory(); expected.Name = "Category Name"; expected.Description = "This is my description of my category"; expected.IsActive = true; expected.QueueId = 1; return expected; }
public abstract void EditCategory(TicketCategory category);
/// <summary> /// Creates shiny new queues that are not referenced / altered by other methods. /// </summary> /// <returns></returns> private Ticket NewTicket() { //Make the complex objects and retunr their ID. TicketQueue que = new TicketQueue(0, "nblevins", "description", "QueueName", TestDate, true); HelpdeskService.CreateQueue(que); TicketCategory cat = new TicketCategory(0, "Category Name", "Category Description", true, que.QueueId); HelpdeskService.CreateCategory(cat); TicketModule mod = new TicketModule(0, que.QueueId, "Module Name", "Description", true); HelpdeskService.CreateModule(mod); Requestor req = new Requestor(0, "nbleivns", "Blevins", "444-444-4444", "*****@*****.**"); HelpdeskService.CreateRequestor(req); TicketStatus stat = new TicketStatus(0, "Status Name", "Description", 1, true); HelpdeskService.CreateStatus(stat); //Set up the ticket... Ticket temp = new Ticket(); temp.Category = cat; temp.CreationDate = TestDate; temp.Creator = "nblevins"; temp.Description = "This is my ticket decription."; temp.DueDate = TestDate + new TimeSpan(2, 0, 0); temp.Module = mod; temp.Priority = TicketPriority.Medium; temp.Requestor = req; temp.Responses = new TicketResponseCollection(); temp.Status = stat; temp.Assignment = new AssignmentCollection(); temp.Queue = que; //Build the company... Company comp = new Company(); comp.Address1 = "addy1"; comp.Address2 = "addy2"; comp.City = "some city"; comp.ContactNumber1 = "444-444-4444"; comp.ContactNumber2 = "322-333-3333"; comp.Name = "New Company"; comp.ParentId = 0; comp.State = "TN"; comp.Website = "www.sworps.com"; comp.Zip_Code = "33333-3333"; Requestor MainReq = new Requestor(); MainReq.ContactNumber = "555-555-5555"; MainReq.Email = "*****@*****.**"; MainReq.FirstName = "nathan 1"; MainReq.LastName = "bleivns 1"; HelpdeskService.CreateRequestor(MainReq); comp.MainContact = MainReq; Requestor SecReq = new Requestor(); SecReq.ContactNumber = "555-222-5555"; SecReq.Email = "*****@*****.**"; SecReq.FirstName = "nathan 2"; SecReq.LastName = "bleivns 2"; HelpdeskService.CreateRequestor(SecReq); comp.SecondaryContact = SecReq; temp.Company = comp; return temp; }
public abstract void CreateCategory(TicketCategory category);
public static void Delete(TicketCategory TicketCategory) { DbCommand cmd = db.GetStoredProcCommand("dbo.DeleteTicketCategory"); db.AddInParameter(cmd, "@TicketCategoryId", DbType.Int32, TicketCategory.Id); }
public static void EditCategory(TicketCategory category) { LoadProviders(); _provider.EditCategory(category); }
public static void CreateCategory(TicketCategory category) { LoadProviders(); _provider.CreateCategory(category); }
public static void Insert(TicketCategory TicketCategory) { //DbCommand cmd = db.GetSqlStringCommand(String.Format("INSERT INTO TicketCategories (Name, BusinessId, DateCreated) VALUES ('{0}', {1}, '{2}');", TicketCategory.Name, TicketCategory.BusinessId, TicketCategory.DateCreated)); //db.ExecuteNonQuery(cmd); //DbCommand cmd = db.GetStoredProcCommand("dbo.InsertTicketCategory"); //db.AddInParameter(cmd, "@Name", DbType.String, TicketCategory.Name); //db.AddInParameter(cmd, "@Email", DbType.String, TicketCategory.Email); //db.AddInParameter(cmd, "@Password", DbType.String, TicketCategory.Password); //db.AddInParameter(cmd, "@BusinessId", DbType.Int32, TicketCategory.Id); //db.ExecuteNonQuery(cmd); }
public static void Update(TicketCategory TicketCategory) { DbCommand cmd = db.GetStoredProcCommand("dbo.UpdateTicketCategory"); db.AddInParameter(cmd, "@Name", DbType.String, TicketCategory.Name); db.AddInParameter(cmd, "@TicketCategoryId", DbType.Int32, TicketCategory.Id); db.ExecuteNonQuery(cmd); }