Example #1
0
 public bool Equals(HelpdeskGroupQuery other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(string.Equals(this.HelpdeskListId, other.HelpdeskListId));
 }
Example #2
0
        public async Task <IList <HelpdeskPreview> > ExecuteAsync(HelpdeskGroupQuery query)
        {
            var helpdeskLists = await this._helpdeskGroupsService.GetHelpdeskGroupsAsync();

            var helpdeskList = helpdeskLists.First(f => f.Id == query.HelpdeskListId);

            var helpdesks = await this._centronService.GetHelpdesksAsync(
                helpdeskList.CustomerI3D,
                helpdeskList.OnlyOwn,
                helpdeskList.HelpdeskStateI3D);

            if (helpdeskList.HelpdeskTypeI3D.HasValue)
            {
                helpdesks = helpdesks
                            .Where(f => f.TypeI3D == helpdeskList.HelpdeskTypeI3D.Value)
                            .ToList();
            }

            if (string.IsNullOrWhiteSpace(helpdeskList.FilterScript) == false)
            {
                var script = this._scriptEngine.CreateFor("return " + helpdeskList.FilterScript);

                helpdesks = helpdesks
                            .Where(f =>
                {
                    script.AddData("nummer", f.Number);
                    script.AddData("kategorie", f.CategoryCaption);
                    script.AddData("unterkategorie1", f.SubCategory1Caption);
                    script.AddData("unterkategorie2", f.SubCategory2Caption);
                    script.AddData("status", f.StatusCaption);
                    script.AddData("priorität", f.PriorityCaption);
                    script.AddData("typ", f.TypeCaption);

                    try
                    {
                        return(script.Execute().AsBoolean());
                    }
                    catch (InvalidScriptException)
                    {
                        return(true);
                    }
                })
                            .ToList();
            }

            return(helpdesks);
        }