예제 #1
0
 public UnitOfWork(CarInsuranceContextV3 db)
 {
     _dbContext = db;
     BrokerPolicyTemplateRepository = new BrokerPolicyTemplateRepository(db);
     CarRepository   = new CarRepository(db);
     CoverRepository = new CoverRepository(db);
 }
 public MainWindowVM()
 {
     ReadWindowsSetting();
     ApplyBase(_isDarkTheme);
     Covers       = CoverRepository.All();
     SummarizerVm = new SummarizerVM(this);
     QuantifierVm = new QuantifierVM(this);
     SummaryVm    = new SummaryVM(SummarizerVm.AttributesList, QuantifierVm.Quantifiers, this);
     Save         = new RelayCommand(OnSave);
     Open         = new RelayCommand(OnOpen);
 }
        internal void UploadCover(object obj)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog
            {
                Filter = "Pliki obrazów (*.jpeg;*.jpg;*.bmp;*.png;*.gif;*.tiff;*tif)|*.jpeg;*.jpg;*.bmp;*.png;*.gif;*.tiff;*tif"
            };

            if (openFileDialog.ShowDialog() == true)
            {
                if (SharedFunctions.ConnectionTest() == false)
                {
                    WarningTaskDialog(obj);
                }
                else
                {
                    Models.MediaElement mediaElement = obj as Models.MediaElement;

                    if (mediaElement.Cover == null)
                    {
                        Task.Factory.StartNew(() =>
                        {
                            string coverPath   = CoverRepository.Upload(openFileDialog.FileName).GetAwaiter().GetResult();
                            mediaElement.Cover = coverPath;
                        })
                        .ContinueWith(next =>
                        {
                            SharedFunctions.ModifyMediaElementCover(Convert.ToInt32(mediaElement.MediaElementId), mediaElement);
                        });
                    }
                    else
                    {
                        Task.Factory.StartNew(() =>
                        {
                            string coverPath   = CoverRepository.Update(openFileDialog.FileName, mediaElement.Cover).GetAwaiter().GetResult();
                            mediaElement.Cover = coverPath;
                        })
                        .ContinueWith(next =>
                        {
                            SharedFunctions.ModifyMediaElementCover(Convert.ToInt32(mediaElement.MediaElementId), mediaElement);
                        });
                    }
                }
            }
        }
예제 #4
0
 public void Setup()
 {
     objects = CoverRepository.All();
 }