public AccOperator RemoveOperator(Line line, AccOperator operatorToRemove)
        {
            var ctxLocalDb = SetDbContext(line);

            ctxLocalDb.AccOperators.Remove(operatorToRemove);
            ctxLocalDb.SaveChanges();

            return(operatorToRemove);
        }
        public AccOperator ChangeOperatorPassword(Line line, AccOperator accOperator)
        {
            //todo: Czy trzeba tu rozwarzyć disconnected scenario?
            var ctx            = SetDbContext(line);
            var editedOperator = ctx.AccOperators.Where(o => o.Operatorid == accOperator.Operatorid).FirstOrDefault();

            if (editedOperator != null)
            {
                editedOperator.Name = accOperator.Name;
                ctx.SaveChanges();
            }
            return(editedOperator);
        }
        public AccOperator AddOperator(Line line, AccOperator newOperator)
        {
            List <string> allowedSysGroupsForNormalOperator = new List <string>
            {
                "SYS-ChangeStatus",
                "SYS-REPRINT",
                "SYS-TAG",
                "SYS-UNITID"
            };

            List <string> forbiddenGroupsForNormalOperator = new List <string>
            {
                "engineer",
                "inżynier",
                "inżynier/diagnosta",
                "diagnosta",
                "asystent"
            };

            var normalOperatorGroupList = GetAllOperatroGroups(line).Where(g => !g.StartsWith("SYS") && !forbiddenGroupsForNormalOperator.Contains(g.ToLower())).ToList();

            normalOperatorGroupList.AddRange(allowedSysGroupsForNormalOperator);

            newOperator.GroupList = string.Join(';', normalOperatorGroupList);
            newOperator.Op        = GetAllLineOps(line);

            //todo: może trzeba wrzucić tworzenie ctx'ów w using?
            var ctxLocalDb = SetDbContext(line);

            ctxLocalDb.AccOperators.Add(newOperator);
            ctxLocalDb.SaveChanges();

            //var ctxFactoryDb = SetDbContext(line, true);
            //ctxFactoryDb.AccOperators.Add(newOperator);
            //ctxFactoryDb.SaveChanges();

            return(newOperator);
        }