Пример #1
0
        ///<summary>Hides all operatories that are not the master op and moves any appointments passed in into the master op.
        ///Throws exceptions</summary>
        public static void MergeOperatoriesIntoMaster(long masterOpNum, List <long> listOpNumsToMerge, List <Appointment> listApptsToMerge)
        {
            //No need to check RemotingRole; No db call.
            List <Operatory> listOps  = Operatories.GetDeepCopy();
            Operatory        masterOp = listOps.FirstOrDefault(x => x.OperatoryNum == masterOpNum);

            if (masterOp == null)
            {
                throw new ApplicationException(Lans.g("Operatories", "Operatory to merge into no longer exists."));
            }
            if (listApptsToMerge.Count > 0)
            {
                //All appts in listAppts are appts that we are going to move to new op.
                List <Appointment> listApptsNew = listApptsToMerge.Select(x => x.Copy()).ToList(); //Copy object so that we do not change original object in memory.
                listApptsNew.ForEach(x => x.Op = masterOpNum);                                     //Associate to new op selection
                Appointments.Sync(listApptsNew, listApptsToMerge, 0);
            }
            List <Operatory> listOpsToMerge = listOps.Select(x => x.Copy()).ToList();        //Copy object so that we do not change original object in memory.

            listOpsToMerge.FindAll(x => x.OperatoryNum != masterOpNum && listOpNumsToMerge.Contains(x.OperatoryNum))
            .ForEach(x => x.IsHidden = true);
            Operatories.Sync(listOpsToMerge, listOps);
            SecurityLogs.MakeLogEntry(Permissions.Setup, 0
                                      , Lans.g("Operatories", "The following operatories and all of their appointments were merged into the")
                                      + " " + masterOp.Abbrev + " " + Lans.g("Operatories", "operatory;") + " "
                                      + string.Join(", ", listOpsToMerge.FindAll(x => x.OperatoryNum != masterOpNum && listOpNumsToMerge.Contains(x.OperatoryNum)).Select(x => x.Abbrev)));
        }