// GET: Ticket public ActionResult Index() { HattrickDBContext ctx = new HattrickDBContext(); ViewTicket model = new ViewTicket(); var query = (from x in ctx.Matches.AsEnumerable() join y in ctx.Footballs.AsEnumerable() on x.IdFootball equals y.IdFootball orderby x.IdTicket select new ViewTicket { IdTicket = x.IdTicket, IdMatch = x.IdMatch, Coefficient = x.Coefficient, FootballGame = y.FootballGame, Time = y.Time, IdFootball = y.IdFootball, }).ToList(); model.ViewTicketList = query; return(View(model)); }
public bool ViewTicket(int ticketId) { ViewTicket viewticket = null; try { var entity = db.Tickets.Find(ticketId); if (entity == null) { return(false); } else { var ticket = from t in db.Tickets.Where(i => i.Id == ticketId) join u in db.Users.DefaultIfEmpty() on t.ClientId equals u.Id select new ViewTicket() { Id = t.Id, Status = t.Status, Category = t.Category, Priority = t.Priority, Title = t.Title, Description = t.Description, ClientName = u.FirstName + " " + u.LastName, OpenDate = t.OpenDate, ClosedDate = t.ClosedDate, ClosedByEmployee = u.FirstName + " " + u.LastName }; // View attachments viewticket = (ViewTicket)ticket; if (viewticket.Attachments.Length > 0) { foreach (var t in viewticket.Attachments) { var attach = from f in db.FileStorages.Where(f => f.Type == AttachmentType.Ticket && f.Reference == ticketId) select new ViewAttachment() { Path = f.Path }; } } // View replys if (entity.Replys != null) { foreach (var r in entity.Replys) { var reply = from rp in db.Replys.Where(rp => rp.TicketId == ticketId) select new ViewReply() { Content = rp.Content, Time = rp.Time }; } } return(true); } } catch (Exception ex) { GlobalVariable.log.Write(LogLevel.Error, ex); return(false); } }
private void RefreshData() { try { _tickets.Clear(); _treeViewSource.Clear(); foreach (var ticket in GetTickets().Result) _tickets.Add(ticket); var contractors = _tickets.Select(t => new {t.RowProperty.Contractor.ID, t.RowProperty.Contractor.Name }).Distinct().ToList(); foreach (var contractor in contractors) { var maitTicket = new ViewTicket(null) {Title = contractor.Name}; foreach (var ticket in _tickets.Where(t => t.RowProperty.Contractor.ID == contractor.ID)) { var viewTicket = new ViewTicket(ticket) {Title = ticket.RowType.Theme}; maitTicket.Children.Add(viewTicket); } _treeViewSource.Add(maitTicket); } var existingTypes = navBar.Groups.Where(t => t.Tag != null).Select(t => t.Tag.ToString()).ToList(); var types = _tickets.Where(t => !String.IsNullOrEmpty(t.RowType.TypeRow)).Select(t => t.RowType.TypeRow).Distinct().ToList(); var newTypes = types.Except(existingTypes).ToList(); var oldTypes = existingTypes.Except(types).ToList(); var activeNavBarGroup = navBar.Groups.FirstOrDefault(t => t.IsActive); foreach (var type in newTypes) { var typeTickets = _treeViewSource.SelectByType(type); AddNavBarGroup(typeTickets); } foreach (var type in oldTypes) { var navBarGroup = navBar.Groups.First(t => t.Tag.ToString().Equals(type)); navBar.Groups.Remove(navBarGroup); } foreach (var type in types) { if (existingTypes.Contains(type)) { var typeTickets = _treeViewSource.SelectByType(type); var navBarGroup = navBar.Groups.First(t => t.Tag.ToString().Equals(type)); navBarGroup.Content = typeTickets; } } if (activeNavBarGroup != null && navBar.Groups.Contains(activeNavBarGroup)) { navBar.ActiveGroup = activeNavBarGroup; } ShowNotification(); } catch (Exception ex) { _log.Error(ex); } }
private void RefreshData() { try { _tickets.Clear(); _treeViewSource.Clear(); foreach (var ticket in GetTickets().Result) { _tickets.Add(ticket); } var contractors = _tickets.Select(t => new { t.RowProperty.Contractor.ID, t.RowProperty.Contractor.Name }).Distinct().ToList(); foreach (var contractor in contractors) { var maitTicket = new ViewTicket(null) { Title = contractor.Name }; foreach (var ticket in _tickets.Where(t => t.RowProperty.Contractor.ID == contractor.ID)) { var viewTicket = new ViewTicket(ticket) { Title = ticket.RowType.Theme }; maitTicket.Children.Add(viewTicket); } _treeViewSource.Add(maitTicket); } var existingTypes = navBar.Groups.Where(t => t.Tag != null).Select(t => t.Tag.ToString()).ToList(); var types = _tickets.Where(t => !String.IsNullOrEmpty(t.RowType.TypeRow)).Select(t => t.RowType.TypeRow).Distinct().ToList(); var newTypes = types.Except(existingTypes).ToList(); var oldTypes = existingTypes.Except(types).ToList(); var activeNavBarGroup = navBar.Groups.FirstOrDefault(t => t.IsActive); foreach (var type in newTypes) { var typeTickets = _treeViewSource.SelectByType(type); AddNavBarGroup(typeTickets); } foreach (var type in oldTypes) { var navBarGroup = navBar.Groups.First(t => t.Tag.ToString().Equals(type)); navBar.Groups.Remove(navBarGroup); } foreach (var type in types) { if (existingTypes.Contains(type)) { var typeTickets = _treeViewSource.SelectByType(type); var navBarGroup = navBar.Groups.First(t => t.Tag.ToString().Equals(type)); navBarGroup.Content = typeTickets; } } if (activeNavBarGroup != null && navBar.Groups.Contains(activeNavBarGroup)) { navBar.ActiveGroup = activeNavBarGroup; } ShowNotification(); } catch (Exception ex) { _log.Error(ex); } }