Exemple #1
0
        public void UpdateProfessional(ProfessionalBuilder builder)
        {
            var professional = builder.Build();

            if (Notification.HasNotification())
            {
                return;
            }

            var keys = new ComposeKey <Guid, decimal>(professional.Code, professional.ProfessionalId);

            if (!_professionalRepository.ExistsProfessional(keys))
            {
                Notification.Raise(NotificationEvent.DefaultBuilder
                                   .WithNotFoundStatus()
                                   .WithMessage(AppConsts.LocalizationSourceName, Professional.Error.CouldNotFindProfessional)
                                   .Build());
            }

            if (Notification.HasNotification())
            {
                return;
            }

            _professionalRepository.UpdateProfessional(professional);
            _professionalRepository.AddOrRemoveSpecialties(keys, professional.Specialties);
        }
Exemple #2
0
        public static void LoadConfig()
        {
            // The key used as the compose key
            ComposeKey.Load();

            if (!m_valid_compose_keys.Contains(ComposeKey.Value))
            {
                ComposeKey.Value = m_default_compose_key;
            }

            // The timeout delay
            ResetDelay.Load();

            // Activate the desired interface language
            Language.Load();

            // HACK: if the user uses the "it-CH" locale, replace it with "it"
            // because we use "it-CH" as a special value to mean Sardinian.
            // The reason is that apparently we cannot define a custom
            // CultureInfo without registering it, and we cannot register it
            // without administrator privileges.
            if (Thread.CurrentThread.CurrentUICulture.Name == "it-CH")
            {
                try
                {
                    Thread.CurrentThread.CurrentUICulture
                        = Thread.CurrentThread.CurrentUICulture.Parent;
                }
                catch (Exception) { }
            }

            if (Language.Value != "")
            {
                if (m_valid_languages.ContainsKey(Language.Value))
                {
                    try
                    {
                        var ci = CultureInfo.GetCultureInfo(Language.Value);
                        Thread.CurrentThread.CurrentUICulture = ci;
                    }
                    catch (Exception) { }
                }
                else
                {
                    Language.Value = "";
                }
            }

            // Catch-22: we can only add this string when the UI language is known
            m_valid_languages[""] = i18n.Text.AutodetectLanguage;

            // Various options
            CaseInsensitive.Load();
            DiscardOnInvalid.Load();
            BeepOnInvalid.Load();
            KeepOriginalKey.Load();
            InsertZwsp.Load();
            EmulateCapsLock.Load();
            ShiftDisablesCapsLock.Load();
        }
Exemple #3
0
        public bool ExistsProfessional(ComposeKey <Guid, decimal> keys)
        {
            var dbEntity = Context.Professionals
                           .SingleOrDefault(s => s.ProfessionalId == keys.SecundaryKey && s.Code == keys.PrimaryKey);

            return(dbEntity != null);
        }
Exemple #4
0
 public static void SaveConfig()
 {
     SaveEntry("reset_delay", m_delay.ToString());
     Language.Save();
     ComposeKey.Save();
     CaseInsensitive.Save();
     DiscardOnInvalid.Save();
     BeepOnInvalid.Save();
     KeepOriginalKey.Save();
     InsertZwsp.Save();
     EmulateCapsLock.Save();
     ShiftDisablesCapsLock.Save();
 }
Exemple #5
0
        public void DeleteProfessional(ComposeKey <Guid, decimal> keys)
        {
            if (!_professionalRepository.ExistsProfessional(keys))
            {
                Notification.Raise(NotificationEvent.DefaultBuilder
                                   .WithNotFoundStatus()
                                   .WithMessage(AppConsts.LocalizationSourceName, Professional.Error.CouldNotFindProfessional)
                                   .Build());
            }

            if (!Notification.HasNotification())
            {
                _professionalRepository.DeleteProfessional(keys);
            }
        }
Exemple #6
0
        public bool DeleteProfessional(ComposeKey <Guid, decimal> keys)
        {
            var dbEntity = Context.Professionals
                           .Include(i => i.ProfessionalSpecialties)
                           .SingleOrDefault(s => s.ProfessionalId == keys.SecundaryKey && s.Code == keys.PrimaryKey);

            if (dbEntity == null)
            {
                return(false);
            }

            dbEntity.ProfessionalSpecialties.ForEach(w => Context.ProfessionalSpecialties.Remove(w));

            Context.Professionals.Remove(dbEntity);

            return(true);
        }
Exemple #7
0
        public void DeleteProfessional(ComposeKey <Guid, decimal> keys)
        {
            var professionalId = keys.SecundaryKey;
            var code           = keys.PrimaryKey;

            if (professionalId <= 0)
            {
                RaiseNotification(nameof(professionalId));
            }

            if (code == Guid.Empty)
            {
                RaiseNotification(nameof(code));
            }

            if (!Notification.HasNotification())
            {
                _service.DeleteProfessional(keys);
            }
        }
Exemple #8
0
        public ProfessionalDto UpdateProfessional(ComposeKey <Guid, decimal> keys, ProfessionalDto professional)
        {
            var professionalId = keys.SecundaryKey;
            var code           = keys.PrimaryKey;

            if (professionalId <= 0)
            {
                RaiseNotification(nameof(professionalId));
            }

            if (code == Guid.Empty)
            {
                RaiseNotification(nameof(code));
            }

            if (professional == null)
            {
                RaiseNotification(nameof(professional));
            }

            if (Notification.HasNotification())
            {
                return(new ProfessionalDto());
            }

            var professionalBuilder = new ProfessionalBuilder(Notification)
                                      .WithProfessionalId(keys.SecundaryKey)
                                      .WithCode(keys.PrimaryKey)
                                      .WithName(professional.Name)
                                      .WithPhone(professional.Phone)
                                      .WithEmail(professional.Email)
                                      .WithAddress(professional.Address)
                                      .WithSpecialties(professional.Specialties.Select(s => new SpecialtyBuilder(Notification).WithId(s.Id).WithDescription(s.Description).Build()).ToList());

            _service.UpdateProfessional(professionalBuilder);

            professional.ProfessionalId = keys.SecundaryKey;
            professional.Code           = keys.PrimaryKey;
            return(professional);
        }
Exemple #9
0
        public void AddOrRemoveSpecialties(ComposeKey <Guid, decimal> keys, IList <Specialty> specialties)
        {
            var request = new RequestDto <ComposeKey <Guid, decimal> >(keys)
            {
                Expand = new ProfessionalDto().Expandables[0]
            };

            var dbProfessional = GetProfessionalPoco(request);

            if (dbProfessional == null)
            {
                return;
            }

            var idsToAdd = specialties.Select(s => s.Id).ToArray();

            if (dbProfessional.ProfessionalSpecialties == null)
            {
                dbProfessional.ProfessionalSpecialties = new List <ProfessionalSpecialtiesPoco>();
            }

            dbProfessional.ProfessionalSpecialties.RemoveAll(w => !idsToAdd.Contains(w.SpecialtyId));

            foreach (var specialty in specialties)
            {
                var dbProfessionalSpecialties = dbProfessional.ProfessionalSpecialties
                                                .FirstOrDefault(s => s.SpecialtyId == specialty.Id);

                if (dbProfessionalSpecialties == null)
                {
                    dbProfessional.ProfessionalSpecialties.Add(new ProfessionalSpecialtiesPoco
                    {
                        ProfessionalId = dbProfessional.ProfessionalId,
                        Code           = dbProfessional.Code,
                        SpecialtyId    = specialty.Id
                    });
                }
            }
        }
Exemple #10
0
        public bool ExistsProfessional(ComposeKey <Guid, decimal> keys)
        {
            var professional = FirstOrDefault(w => w.ProfessionalId == keys.SecundaryKey && w.Code == keys.PrimaryKey);

            return(professional != null);
        }
Exemple #11
0
 public ProfessionalBuilder WithIds(ComposeKey <Guid, decimal> keys)
 {
     Instance.Code           = keys.PrimaryKey;
     Instance.ProfessionalId = keys.SecundaryKey;
     return(this);
 }