private int AddSourceIfNotExist(int ClientId, string sourcename, int?sourcetypeid)
        {
            Source new_source = _sourceRep.FindBy(t => t.Name == sourcename && t.ClientId == ClientId && (sourcetypeid == null ? t.SourceTypeId == null : t.SourceTypeId == sourcetypeid)).FirstOrDefault();

            if (new_source == null)
            {
                new_source = new Source()
                {
                    Name = sourcename, ClientId = ClientId, SourceTypeId = sourcetypeid
                };
                _sourceRep.Add(new_source);
                _sourceRep.Save();
            }

            return(new_source.Id);
        }