Example #1
0
        public virtual Tuple <bool, bool> AccessViewAndEditProfile(Employee employee)
        {
            logger.Info($"Вычисление уровня доступа к профилю работника {employee}...");
            Tuple <bool, bool> res             = Tuple.Create(false, false);
            Employee           currentEmployee = HospitalManager.GetCurrentEmployee();

            if (currentEmployee.Equals(employee))
            {
                if (HospitalManager.IsMainManager(employee))
                {
                    res = Tuple.Create(true, true);
                }
                else
                {
                    res = Tuple.Create(true, false);
                }
            }
            else
            {
                if (currentEmployee.Role == UserRole.егистратор || currentEmployee.Role == UserRole.Врач)
                {
                    res = Tuple.Create(false, false);
                }
                if (currentEmployee.Role == UserRole.Менеджер)
                {
                    if (currentEmployee.Profile.Priority < employee.Profile.Priority)
                    {
                        res = Tuple.Create(false, false);
                    }
                    else if (currentEmployee.Profile.Priority == employee.Profile.Priority)
                    {
                        res = Tuple.Create(true, false);
                    }
                    else if (currentEmployee.Profile.Priority > employee.Profile.Priority)
                    {
                        res = Tuple.Create(true, true);
                    }
                }
            }
            logger.Info($"Уровень доступа к профилю работника {employee} вычислен");
            return(res);
        }
Example #2
0
 public AddOrEditDiagnosisForm(Patient patient, Diagnosis diagnosis = default)
 {
     InitializeComponent();
     if (patient is null)
     {
         throw new ArgumentNullException("Отсутсвует пациет");
     }
     _patient = patient;
     _doctor  = HospitalManager.GetCurrentEmployee();
     if (_doctor is null)
     {
         throw new ArgumentNullException("Отсутсвует врач");
     }
     if (_doctor.Role != UserRole.Врач)
     {
         throw new ArgumentException("Вы не врач!");
     }
     if (!(diagnosis is null))
     {
         _diagnosis = diagnosis;
     }
 }