private void OnUpdateFreeTag(string obj) { var cachedTag = AppServices.MainDataContext.SelectedDepartment.TicketTagGroups.Single( x => x.Id == SelectedTicket.LastSelectedTicketTag.Id); Debug.Assert(cachedTag != null); var ctag = cachedTag.TicketTags.SingleOrDefault(x => x.Name.ToLower() == FreeTag.ToLower()); if (ctag == null && cachedTag.SaveFreeTags) { using (var workspace = WorkspaceFactory.Create()) { var tt = workspace.Single <TicketTagGroup>(x => x.Id == SelectedTicket.LastSelectedTicketTag.Id); Debug.Assert(tt != null); var tag = tt.TicketTags.SingleOrDefault(x => x.Name.ToLower() == FreeTag.ToLower()); if (tag == null) { tag = new TicketTag { Name = FreeTag }; tt.TicketTags.Add(tag); workspace.Add(tag); workspace.CommitChanges(); } } } SelectedTicket.UpdateTag(SelectedTicket.LastSelectedTicketTag, new TicketTag { Name = FreeTag }); FreeTag = string.Empty; }
private void OnTicketTagSelected(TicketTag obj) { SelectedTicket.UpdateTag(SelectedTicket.LastSelectedTicketTag, obj); }