Esempio n. 1
0
        ///<summary>Does nothing and returns false if checkOrderAlphabetical is checked.  Uses ClinicSort to put the clinics in the correct order and then
        ///updates the ItemOrder for all clinics.  Includes hidden clinics and clinics the user does not have permission to access.  It must include all
        ///clinics for the ordering to be correct for all users.  This method corrects item ordering issues that were caused by past code and is just a
        ///precaution.  After this runs once, there shouldn't be any ItemOrder inconsistencies moving forward, so this should generally just return false.
        ///Returns true if the db was changed.</summary>
        private bool CorrectItemOrders()
        {
            if (checkOrderAlphabetical.Checked)
            {
                return(false);
            }
            List <Clinic> listAllClinicsDb  = Clinics.GetClinicsNoCache();        //get all clinics, even hidden ones, in order to set the ItemOrders correctly
            List <Clinic> listAllClinicsNew = listAllClinicsDb.Select(x => x.Copy()).ToList();
            bool          isHqInList        = IncludeHQInList;

            IncludeHQInList = false;
            listAllClinicsNew.Sort(ClinicSort);
            IncludeHQInList = isHqInList;
            for (int i = 0; i < listAllClinicsNew.Count; i++)
            {
                listAllClinicsNew[i].ItemOrder = i + 1;            //1 based ItemOrder because the HQ 'clinic' has ItemOrder 0
            }
            return(Clinics.Sync(listAllClinicsNew, listAllClinicsDb));
        }