public QuickWindowViewModel(object item)
 {
     Item = item;
     if (Item is Announcement)
     {
         Info        = (Item as Announcement).Info;
         Title       = $"Информация о объявлении {(Item as Announcement).Name}";
         Name        = (Item as Announcement).Name;
         Region      = regionRepository.getRegion((Item as Announcement).idRegion.Value);
         ContactInfo = $"Mail: {userRepository.getById((Item as Announcement).seller).Mail}\n" +
                       $"Телефон: {userRepository.getById((Item as Announcement).seller).TelNumber}\n";
         About = $"{(Item as Announcement).About}\n";
         Cost  = Decimal.Round((Item as Announcement).Cost, 2);
     }
     else if (Item is TmpAnnouncement)
     {
         Info        = (Item as TmpAnnouncement).Info;
         Title       = $"Информация о объявлении {(Item as TmpAnnouncement).Name}";
         Name        = (Item as TmpAnnouncement).Name;
         Region      = regionRepository.getRegion((Item as TmpAnnouncement).idRegion.Value);
         ContactInfo = $"Mail: {userRepository.getById((Item as TmpAnnouncement).seller).Mail}\n" +
                       $"Телефон: {userRepository.getById((Item as TmpAnnouncement).seller).TelNumber}\n";
         About = $"{(Item as TmpAnnouncement).About}\n";
         Cost  = Decimal.Round((Item as TmpAnnouncement).Cost, 2);
     }
     else
     {
         AlertWindow alertWindow = new AlertWindow("Ошибка типа данных!");
         alertWindow.ShowDialog();
     }
 }
Exemplo n.º 2
0
        public BitmapImage LoadPhoto(int seller)
        {
            BitmapImage bitmapImage = new BitmapImage();

            if (userRepository.getById(seller).image != null)
            {
                using (var ms = new MemoryStream(userRepository.getById(seller).image))
                {
                    bitmapImage.BeginInit();
                    bitmapImage.CacheOption  = BitmapCacheOption.OnLoad;
                    bitmapImage.StreamSource = ms;
                    bitmapImage.EndInit();
                }
            }
            return(bitmapImage);
        }