Ejemplo n.º 1
0
 public MainViewModel(
     ISqliteService sqliteService,
     IRealmService realmService)
 {
     _sqliteService = sqliteService;
     _realmService  = realmService;
 }
Ejemplo n.º 2
0
#pragma warning disable 4014
        public SettingsRepository(IStorageService storageService, ISqliteService sqliteService, IPlatformCodeService platformCodeService)
        {
            _storageService      = storageService;
            _sqliteService       = sqliteService;
            _platformCodeService = platformCodeService;
            Initialize();
        }
Ejemplo n.º 3
0
#pragma warning disable 4014
        public SettingsRepository(IStorageService storageService, ISqliteService sqliteService, IPlatformCodeService platformCodeService)
        {
            _storageService = storageService;
            _sqliteService = sqliteService;
            _platformCodeService = platformCodeService;
            Initialize();
        }
Ejemplo n.º 4
0
 public TodoListViewModel(
     INavigationService navigationService,
     ISqliteService sqliteService)
 {
     _navigationService = navigationService;
     _sqliteService     = sqliteService;
 }
Ejemplo n.º 5
0
		public RecipeItemViewModel(
			INavigationService navigationService,
			ISqliteService sqliteService)
		{
			_navigationService = navigationService;
			_sqliteService = sqliteService;
		}
Ejemplo n.º 6
0
        public PlanificationPageViewModel(INavigationService navigationService, ISqliteService sqliteService) : base(navigationService)
        {
            Pills = sqliteService.Get <Pill>().Result;
            Pill  = Pills[0];

            StartDate = DateTime.Today;

            Periodicities = new List <Periodicity>()
            {
                new Periodicity {
                    Id = (int)PlanificationType.Daily, Description = "Diaria", NextPage = "DailyPlanificationPage"
                },
                new Periodicity {
                    Id = (int)PlanificationType.Weekly, Description = "Semanal", NextPage = "WeeklyPlanificationPage"
                },
                new Periodicity {
                    Id = (int)PlanificationType.Custom, Description = "Personalizada", NextPage = "CustomPlanificationPage"
                }
            };
            Periodicity   = Periodicities[0];
            CriticalStock = "0";
            QtyToDispense = "1";

            CancelCommand = new DelegateCommand(async() => await NavigationService.GoBackAsync());
            NextCommand   = new DelegateCommand(async() => await NextAsync());
        }
 public PublishTrades(IOptions <PublishTradesOptions> options, ILogger <PublishTrades> logger)
 {
     _logger          = logger;
     _localImport     = options.Value.LocalImportService;
     _discord         = options.Value.DiscordService;
     _sqlite          = options.Value.SqliteService;
     _refreshInterval = options.Value.RefreshInterval;
 }
Ejemplo n.º 8
0
        public ImageDownloadService(IPlatformCodeService platformCodeService, ISqliteService sqliteService, IPermissionsService permissionsService, IProgressService progressService)
        {
            _platformCodeService = platformCodeService;
            _permissionsService = permissionsService;
            _progressService = progressService;

            _maxHeight = _platformCodeService.DeviceHeight();
            _maxWidth = _platformCodeService.DeviceWidth();

            _genericRepository = new GenericRepository<ImageContentModel, ImageContentEntity>(sqliteService);
        }
Ejemplo n.º 9
0
        public ImageDownloadService(IPlatformCodeService platformCodeService, ISqliteService sqliteService, IPermissionsService permissionsService, IProgressService progressService)
        {
            _platformCodeService = platformCodeService;
            _permissionsService  = permissionsService;
            _progressService     = progressService;

            _maxHeight = _platformCodeService.DeviceHeight();
            _maxWidth  = _platformCodeService.DeviceWidth();

            _genericRepository = new GenericRepository <ImageContentModel, ImageContentEntity>(sqliteService);
        }
Ejemplo n.º 10
0
 public static async Task SaveArticle(ArticleModel model, ISqliteService service)
 {
     CleanUp(model);
     var articleGenericRepository = new GenericRepository<ArticleModel, ArticleEntity>(service);
     await articleGenericRepository.SaveAsyc(model);
     if (model.AfterSaveFunc != null)
     {
         var func = model.AfterSaveFunc;
         model.AfterSaveFunc = null;
         await func();
     }
 }
        public SurveysService()
        {
            _rest = DependencyService
                    .Get <IRest>();

            _server = DependencyService
                      .Get <INfieldServer>();

            _sqlite = DependencyService
                      .Get <ISqliteService <SurveyDetailsEntity> >();

            _surveyCounts = DependencyService.Get <ISurveyCountsService>();
        }
Ejemplo n.º 12
0
        public static async Task SaveArticle(ArticleModel model, ISqliteService service)
        {
            CleanUp(model);
            var articleGenericRepository = new GenericRepository <ArticleModel, ArticleEntity>(service);
            await articleGenericRepository.SaveAsyc(model);

            if (model.AfterSaveFunc != null)
            {
                var func = model.AfterSaveFunc;
                model.AfterSaveFunc = null;
                await func();
            }
        }
Ejemplo n.º 13
0
#pragma warning disable 4014
        public ArticleRepository(ISettingsRepository settingsRepository, IProgressService progressService, IStorageService storageService, ISqliteService sqliteService, IThemeRepository themeRepository, IImageDownloadService imageDownloadService, IPermissionsService permissionsService)
        {
            _settingsRepository   = settingsRepository;
            _progressService      = progressService;
            _storageService       = storageService;
            _sqliteService        = sqliteService;
            _themeRepository      = themeRepository;
            _imageDownloadService = imageDownloadService;
            _permissionsService   = permissionsService;

            _articleGenericRepository        = new GenericRepository <ArticleModel, ArticleEntity>(_sqliteService);
            _imageContentGenericRepository   = new GenericRepository <ImageContentModel, ImageContentEntity>(_sqliteService);
            _textContentGenericRepository    = new GenericRepository <TextContentModel, TextContentEntity>(_sqliteService);
            _galleryContentGenericRepository = new GenericRepository <GalleryContentModel, GalleryContentEntity>(_sqliteService);

            Initialize();
        }
Ejemplo n.º 14
0
#pragma warning disable 4014
        public ArticleRepository(ISettingsRepository settingsRepository, IProgressService progressService, IStorageService storageService, ISqliteService sqliteService, IThemeRepository themeRepository, IImageDownloadService imageDownloadService, IPermissionsService permissionsService)
        {
            _settingsRepository = settingsRepository;
            _progressService = progressService;
            _storageService = storageService;
            _sqliteService = sqliteService;
            _themeRepository = themeRepository;
            _imageDownloadService = imageDownloadService;
            _permissionsService = permissionsService;

            _articleGenericRepository = new GenericRepository<ArticleModel, ArticleEntity>(_sqliteService);
            _imageContentGenericRepository = new GenericRepository<ImageContentModel, ImageContentEntity>(_sqliteService);
            _textContentGenericRepository = new GenericRepository<TextContentModel, TextContentEntity>(_sqliteService);
            _galleryContentGenericRepository = new GenericRepository<GalleryContentModel, GalleryContentEntity>(_sqliteService);

            Initialize();
        }
Ejemplo n.º 15
0
        public static async Task<ArticleModel> LoadForFeed(int id, FeedModel feed, ISqliteService sqliteService, IImageDownloadService imageDownloadService)
        {
            var arRepo = new GenericRepository<ArticleModel, ArticleEntity>(sqliteService);
            var imgRepo = new GenericRepository<ImageContentModel, ImageContentEntity>(sqliteService);

            var art = await arRepo.GetByIdAsync(id);
            var contents = await sqliteService.GetByCondition<ContentEntity>(s => s.ParentId == id && s.ContentType == (int)ContentType.LeadImage, s => s.Index, false, 1, 0);
            if (contents?.FirstOrDefault() != null)
            {
                var image = await imgRepo.GetByIdAsync(contents.FirstOrDefault().ContentId);
                art.LeadImage = image;

                if (art.LeadImage?.LoadingState < LoadingState.Loaded)
                    imageDownloadService.Download(art);
            }
            art.Feed = feed;
            return art;
        }
Ejemplo n.º 16
0
        public static async Task SaveArticleLeadImage(ArticleModel model, ISqliteService service, bool skipCleaning = false)
        {
            var imageContentGenericRepository  = new GenericRepository <ImageContentModel, ImageContentEntity>(service);
            List <ContentEntity> oldLeadImages = null;
            var articleId = model.GetId();

            if (!skipCleaning)
            {
                oldLeadImages = (await service.GetByCondition <ContentEntity>(e => e.ParentId == articleId && e.ContentType == (int)ContentType.LeadImage, null, false, 0, 0)).ToList();
            }

            if (model.LeadImage != null)
            {
                if (model.LeadImage.GetId() != 0)
                {
                    var leadImageId  = model.LeadImage.GetId();
                    var oldLeadImage = oldLeadImages?.FirstOrDefault(o => o.ContentId == leadImageId);
                    if (oldLeadImage != null)
                    {
                        oldLeadImages?.Remove(oldLeadImage);
                    }

                    await imageContentGenericRepository.SaveAsyc(model.LeadImage);
                }
                else
                {
                    await imageContentGenericRepository.SaveAsyc(model.LeadImage);

                    var entity = new ContentEntity
                    {
                        ContentId   = model.LeadImage.GetId(),
                        ParentId    = model.GetId(),
                        Index       = 0,
                        ContentType = (int)ContentType.LeadImage
                    };
                    await service.Add(entity);
                }
            }

            if (!skipCleaning)
            {
                await service.DeleteAllById <ContentEntity>(oldLeadImages.Select(d => d.Id));
            }
        }
Ejemplo n.º 17
0
        public DataTable TestService(ISqliteService inputValues)
        {
            if (ThrowsTestError)
            {
                throw new Exception("bob");
            }

            if (HasRecError)
            {
                return(null);
            }
            var dt = new DataTable();

            dt.Columns.Add("a");
            dt.Columns.Add("b");
            dt.Columns.Add("c");
            dt.TableName = "bob";
            return(dt);
        }
Ejemplo n.º 18
0
        public static async Task <ArticleModel> LoadForFeed(int id, FeedModel feed, ISqliteService sqliteService, IImageDownloadService imageDownloadService)
        {
            var arRepo  = new GenericRepository <ArticleModel, ArticleEntity>(sqliteService);
            var imgRepo = new GenericRepository <ImageContentModel, ImageContentEntity>(sqliteService);

            var art = await arRepo.GetByIdAsync(id);

            var contents = await sqliteService.GetByCondition <ContentEntity>(s => s.ParentId == id && s.ContentType == (int)ContentType.LeadImage, s => s.Index, false, 1, 0);

            if (contents?.FirstOrDefault() != null)
            {
                var image = await imgRepo.GetByIdAsync(contents.FirstOrDefault().ContentId);

                art.LeadImage = image;

                if (art.LeadImage?.LoadingState < LoadingState.Loaded)
                {
                    imageDownloadService.Download(art);
                }
            }
            art.Feed = feed;
            return(art);
        }
Ejemplo n.º 19
0
        public static async Task SaveArticleLeadImage(ArticleModel model, ISqliteService service, bool skipCleaning = false)
        {
            var imageContentGenericRepository = new GenericRepository<ImageContentModel, ImageContentEntity>(service);
            List<ContentEntity> oldLeadImages = null;
            var articleId = model.GetId();
            if (!skipCleaning)
                oldLeadImages = (await service.GetByCondition<ContentEntity>(e => e.ParentId == articleId && e.ContentType == (int)ContentType.LeadImage, null, false, 0, 0)).ToList();

            if (model.LeadImage != null)
            {
                if (model.LeadImage.GetId() != 0)
                {
                    var leadImageId = model.LeadImage.GetId();
                    var oldLeadImage = oldLeadImages?.FirstOrDefault(o => o.ContentId == leadImageId);
                    if (oldLeadImage != null)
                        oldLeadImages?.Remove(oldLeadImage);

                    await imageContentGenericRepository.SaveAsyc(model.LeadImage);
                }
                else
                {
                    await imageContentGenericRepository.SaveAsyc(model.LeadImage);

                    var entity = new ContentEntity
                    {
                        ContentId = model.LeadImage.GetId(),
                        ParentId = model.GetId(),
                        Index = 0,
                        ContentType = (int)ContentType.LeadImage
                    };
                    await service.Add(entity);
                }
            }

            if (!skipCleaning)
                await service.DeleteAllById<ContentEntity>(oldLeadImages.Select(d => d.Id));
        }
Ejemplo n.º 20
0
        public static async Task SaveArticleContent(ArticleModel model, ISqliteService service, bool skipCleaning = false)
        {
            var imageContentGenericRepository = new GenericRepository<ImageContentModel, ImageContentEntity>(service);
            var textContentGenericRepository = new GenericRepository<TextContentModel, TextContentEntity>(service);
            var galleryContentGenericRepository = new GenericRepository<GalleryContentModel, GalleryContentEntity>(service);

            var supportedContents = new[] { (int)ContentType.Text, (int)ContentType.Gallery, (int)ContentType.Image };
            List<ContentEntity> oldModels = null;
            if (!skipCleaning)
            {
                var id = model.GetId();
                oldModels = (await service.GetByCondition<ContentEntity>(e => e.ParentId == id, null, false, 0, 0)).ToList();
                oldModels = oldModels.Where(e => supportedContents.Any(s => s == e.ContentType)).ToList();
            }
            for (int i = 0; i < model.Content.Count; i++)
            {
                var baseContentModel = model.Content[i];

                ContentEntity entity = null;
                if (!skipCleaning)
                {
                    entity = oldModels.FirstOrDefault(m => m.ContentId == baseContentModel.GetId());
                    oldModels.Remove(entity);
                }

                if (entity == null)
                    entity = new ContentEntity();

                if (baseContentModel is TextContentModel)
                {
                    var text = (TextContentModel)baseContentModel;
                    text.ContentJson = JsonConvert.SerializeObject(text.Content);
                    await textContentGenericRepository.SaveAsyc(text);
                    entity.ContentType = (int)ContentType.Text;
                }
                else if (baseContentModel is ImageContentModel)
                {
                    var image = (ImageContentModel)baseContentModel;
                    if (image.Text != null)
                    {
                        await textContentGenericRepository.SaveAsyc(image.Text);
                        image.TextContentId = image.Text.GetId();
                    }
                    await imageContentGenericRepository.SaveAsyc(image);
                    entity.ContentType = (int)ContentType.Image;
                }
                else if (baseContentModel is GalleryContentModel)
                {
                    var gallery = (GalleryContentModel)baseContentModel;
                    if (gallery.Text != null)
                    {
                        await textContentGenericRepository.SaveAsyc(gallery.Text);
                        gallery.TextContentId = gallery.Text.GetId();
                    }
                    await galleryContentGenericRepository.SaveAsyc(gallery);
                    for (int index = 0; index < gallery.Images.Count; index++)
                    {
                        gallery.Images[index].GalleryId = gallery.GetId();
                        gallery.Images[index].GalleryIndex = index;
                        if (gallery.Images[index].Text != null)
                        {
                            await textContentGenericRepository.SaveAsyc(gallery.Images[index].Text);
                            gallery.Images[index].TextContentId = gallery.Images[index].Text.GetId();
                        }
                        await imageContentGenericRepository.SaveAsyc(gallery.Images[index]);
                    }
                    entity.ContentType = (int)ContentType.Gallery;
                }
                else
                {
                    continue;
                }
                entity.ContentId = baseContentModel.GetId();
                entity.ParentId = model.GetId();
                entity.Index = i;
                if (entity.Id == 0)
                    await service.Add(entity);
                else
                    await service.Update(entity);
            }

            if (!skipCleaning && oldModels != null)
                foreach (var contentEntity in oldModels)
                {
                    await service.DeleteById<ContentEntity>(contentEntity.Id);
                }
        }
Ejemplo n.º 21
0
        public static async Task SaveFeed(FeedModel model, List <ArticleModel> newArticles, ISqliteService service, IImageDownloadService imageDownloadService)
        {
            var stringGuid  = model.Guid.ToString();
            var feedEntries = await service.GetByCondition <FeedArticleRelationEntity>(d => d.FeedGuid == stringGuid, null, false, 0, 0);

            var oldArticles = new List <ArticleModel>(model.AllArticles);


            for (int index = 0; index < newArticles.Count; index++)
            {
                var articleModel = newArticles[index];
                articleModel.Feed = model;

                var oldOne = oldArticles.FirstOrDefault(s => s.PublicUri == articleModel.PublicUri);
                if (oldOne == null)
                {
                    var oldFromDatabase = feedEntries.FirstOrDefault(s => articleModel.PublicUri == s.Url);
                    if (oldFromDatabase != null)
                    {
                        var article = await LoadHelper.LoadForFeed(oldFromDatabase.ArticleId, model, service, imageDownloadService);

                        feedEntries.Remove(oldFromDatabase);
                        oldFromDatabase.Index = index;
                        await service.Update(oldFromDatabase);

                        if (model.AllArticles.Count > index)
                        {
                            model.AllArticles[index] = article;
                        }
                        else
                        {
                            model.AllArticles.Add(article);
                        }
                    }
                    else
                    {
                        await SaveArticle(articleModel, service);
                        await SaveArticleLeadImage(articleModel, service, true);
                        await SaveArticleContent(articleModel, service, true);

                        var fe = new FeedArticleRelationEntity()
                        {
                            ArticleId = articleModel.GetId(),
                            Url       = articleModel.PublicUri,
                            FeedGuid  = model.Guid.ToString(),
                            Index     = index
                        };
                        await service.Add(fe);

                        if (model.AllArticles.Count > index)
                        {
                            model.AllArticles[index] = articleModel;
                        }
                        else
                        {
                            model.AllArticles.Add(articleModel);
                        }
                    }
                }
                else
                {
                    if (model.AllArticles.Count > index)
                    {
                        model.AllArticles[index] = oldOne;
                    }
                    else
                    {
                        model.AllArticles.Add(oldOne);
                    }

                    var oldFromDatabase = feedEntries.FirstOrDefault(s => articleModel.PublicUri == s.Url);
                    if (oldFromDatabase != null)
                    {
                        oldFromDatabase.Index = index;
                        await service.Update(oldFromDatabase);
                    }
                    else
                    {
                        var fe = new FeedArticleRelationEntity()
                        {
                            ArticleId = oldOne.GetId(),
                            Url       = oldOne.PublicUri,
                            FeedGuid  = model.Guid.ToString(),
                            Index     = index
                        };
                        await service.Add(fe);
                    }
                }
            }

            await service.DeleteAllById <FeedArticleRelationEntity>(feedEntries.Select(s => s.Id));
        }
Ejemplo n.º 22
0
        public ManagerPage()
        {
            InitializeComponent();
            switchOnListen = true;

            ToolbarItems.Add(new ToolbarItem("Delete", "", () =>
            {
                _sqlite.DeleteAll();
            }));

            ToolbarItems.Add(new ToolbarItem("StopListen", "", () =>
            {
                Task.Run(async() => await SendMessage("managerId", "stop"));
                switchOnListen = false;
            }));

            Device.StartTimer(TimeSpan.FromSeconds(5), () =>
            {
                Task.Run(async() => await SendMessage("managerId", "start"));
                return(switchOnListen);
            });

            Device.StartTimer(TimeSpan.FromSeconds(5), () =>
            {
                return(true);
            });

            _sqlite = DependencyService
                      .Get <ISqliteService <InterviewerEntity> >();

            var client = new ClientHandler("Manager", "SendMessageInterviewer");

            Task.Run(async() => await client.StartAsync());
            var interviewer = new Label();
            var watchGrid   = new Grid();

            client.Message += (sender, e) =>
            {
                if (e.Id != "managerId")
                {
                    var interviewerEntity = new InterviewerEntity {
                        InterviewerId = e.Id
                    };
                    var interviewerExist        = _sqlite.Get().Any(x => x.InterviewerId == e.Id);
                    var initialInterviewerCount = _sqlite.Get().Count();

                    if (!interviewerExist)
                    {
                        _sqlite.Add(interviewerEntity);
                    }

                    var interviewerAddedCount = _sqlite.Get().Count();

                    Device.BeginInvokeOnMainThread(() =>
                    {
                        var stack = new StackLayout();

                        int numberOfRows = watchGrid.RowDefinitions.Count;
                        var column       = 0;
                        var row          = 0;

                        if (numberOfRows > 0)
                        {
                            var numberOfChildren = watchGrid.Children.Count;
                            if (interviewerAddedCount % 2 != 0 && initialInterviewerCount != interviewerAddedCount)
                            {
                                watchGrid.RowDefinitions.Add(new RowDefinition {
                                    Height = new GridLength(600)
                                });
                            }

                            for (int childIndex = 0; childIndex < numberOfChildren; ++childIndex)
                            {
                                var view    = watchGrid.Children[childIndex];
                                var element = ((StackLayout)view).Children.ElementAt(0);
                                row         = Grid.GetRow(watchGrid.Children[childIndex]);
                                column      = Grid.GetColumn(watchGrid.Children[childIndex]);

                                if (interviewerAddedCount % 2 != 0 && initialInterviewerCount != interviewerAddedCount)
                                {
                                    row++;
                                }

                                if (((Label)element).Text == e.Id)
                                {
                                    watchGrid.Children.RemoveAt(childIndex);
                                    stack = new ContentViewBuilder().Build(e.Message, e.Id);
                                    watchGrid.Children.Add(stack, column, row);
                                    break;
                                }

                                if (((Label)element).Text != e.Id && row == Grid.GetRow(watchGrid.Children[childIndex]) && initialInterviewerCount != interviewerAddedCount)
                                {
                                    stack = new ContentViewBuilder().Build(e.Message, e.Id);
                                    watchGrid.Children.Add(stack, column + 1, row);
                                    break;
                                }

                                if (((Label)element).Text != e.Id && row != Grid.GetRow(watchGrid.Children[childIndex]) && initialInterviewerCount != interviewerAddedCount)
                                {
                                    stack = new ContentViewBuilder().Build(e.Message, e.Id);
                                    watchGrid.Children.Add(stack, column, row);
                                    break;
                                }
                            }
                        }
                        else
                        {
                            watchGrid.ColumnDefinitions.Add(new ColumnDefinition {
                                Width = new GridLength(300)
                            });
                            watchGrid.ColumnDefinitions.Add(new ColumnDefinition {
                                Width = new GridLength(300)
                            });
                            watchGrid.RowDefinitions.Add(new RowDefinition {
                                Height = new GridLength(600)
                            });

                            stack = new ContentViewBuilder().Build(e.Message, e.Id);
                            watchGrid.Children.Add(stack, 0, 0);
                        }

                        Content = watchGrid;
                    });
                }
            };
        }
Ejemplo n.º 23
0
        public static async Task SaveArticleContent(ArticleModel model, ISqliteService service, bool skipCleaning = false)
        {
            var imageContentGenericRepository   = new GenericRepository <ImageContentModel, ImageContentEntity>(service);
            var textContentGenericRepository    = new GenericRepository <TextContentModel, TextContentEntity>(service);
            var galleryContentGenericRepository = new GenericRepository <GalleryContentModel, GalleryContentEntity>(service);

            var supportedContents          = new[] { (int)ContentType.Text, (int)ContentType.Gallery, (int)ContentType.Image };
            List <ContentEntity> oldModels = null;

            if (!skipCleaning)
            {
                var id = model.GetId();
                oldModels = (await service.GetByCondition <ContentEntity>(e => e.ParentId == id, null, false, 0, 0)).ToList();
                oldModels = oldModels.Where(e => supportedContents.Any(s => s == e.ContentType)).ToList();
            }
            for (int i = 0; i < model.Content.Count; i++)
            {
                var baseContentModel = model.Content[i];

                ContentEntity entity = null;
                if (!skipCleaning)
                {
                    entity = oldModels.FirstOrDefault(m => m.ContentId == baseContentModel.GetId());
                    oldModels.Remove(entity);
                }

                if (entity == null)
                {
                    entity = new ContentEntity();
                }

                if (baseContentModel is TextContentModel)
                {
                    var text = (TextContentModel)baseContentModel;
                    text.ContentJson = JsonConvert.SerializeObject(text.Content);
                    await textContentGenericRepository.SaveAsyc(text);

                    entity.ContentType = (int)ContentType.Text;
                }
                else if (baseContentModel is ImageContentModel)
                {
                    var image = (ImageContentModel)baseContentModel;
                    if (image.Text != null)
                    {
                        await textContentGenericRepository.SaveAsyc(image.Text);

                        image.TextContentId = image.Text.GetId();
                    }
                    await imageContentGenericRepository.SaveAsyc(image);

                    entity.ContentType = (int)ContentType.Image;
                }
                else if (baseContentModel is GalleryContentModel)
                {
                    var gallery = (GalleryContentModel)baseContentModel;
                    if (gallery.Text != null)
                    {
                        await textContentGenericRepository.SaveAsyc(gallery.Text);

                        gallery.TextContentId = gallery.Text.GetId();
                    }
                    await galleryContentGenericRepository.SaveAsyc(gallery);

                    for (int index = 0; index < gallery.Images.Count; index++)
                    {
                        gallery.Images[index].GalleryId    = gallery.GetId();
                        gallery.Images[index].GalleryIndex = index;
                        if (gallery.Images[index].Text != null)
                        {
                            await textContentGenericRepository.SaveAsyc(gallery.Images[index].Text);

                            gallery.Images[index].TextContentId = gallery.Images[index].Text.GetId();
                        }
                        await imageContentGenericRepository.SaveAsyc(gallery.Images[index]);
                    }
                    entity.ContentType = (int)ContentType.Gallery;
                }
                else
                {
                    continue;
                }
                entity.ContentId = baseContentModel.GetId();
                entity.ParentId  = model.GetId();
                entity.Index     = i;
                if (entity.Id == 0)
                {
                    await service.Add(entity);
                }
                else
                {
                    await service.Update(entity);
                }
            }

            if (!skipCleaning && oldModels != null)
            {
                foreach (var contentEntity in oldModels)
                {
                    await service.DeleteById <ContentEntity>(contentEntity.Id);
                }
            }
        }
Ejemplo n.º 24
0
 public RealDataService(IRestService restService, ISqliteService sqliteService)
 {
     _restService   = restService;
     _sqliteService = sqliteService;
 }
Ejemplo n.º 25
0
        public ThemeRepository(ISqliteService sqliteService)
        {
            _sqliteService = sqliteService;

            _themeGenericRepository = new GenericRepository<ThemeModel, ThemeEntity>(_sqliteService);
        }
Ejemplo n.º 26
0
 public SetFavourites()
 {
     _sqlite = DependencyService
               .Get <ISqliteService <SurveyDetailsEntity> >();
 }
Ejemplo n.º 27
0
 /// <summary>
 /// Create the process and send the message to the queue for the function to pick up and start processing
 /// </summary>
 public CreateProcessViewModel()
 {
     _sqlite = DependencyService.Get <ISqliteService <ProcessEntity> >();
     _azure  = DependencyService.Get <IAzureService>();
 }
Ejemplo n.º 28
0
 public DbBuilder(string tableName, ISqliteService sqliteService)
 {
     _tableName         = tableName;
     this.sqliteService = sqliteService;
 }
Ejemplo n.º 29
0
        public ThemeRepository(ISqliteService sqliteService)
        {
            _sqliteService = sqliteService;

            _themeGenericRepository = new GenericRepository <ThemeModel, ThemeEntity>(_sqliteService);
        }
 /// <summary>
 /// Get list of processes created and order them by putting the latest process at the top of the list
 /// </summary>
 public GetProcessListViewModel()
 {
     _sqlite     = DependencyService.Get <ISqliteService <ProcessEntity> >();
     _processIds = Get();
 }
Ejemplo n.º 31
0
        public static async Task SaveFeed(FeedModel model, List<ArticleModel> newArticles, ISqliteService service, IImageDownloadService imageDownloadService)
        {
            var stringGuid = model.Guid.ToString();
            var feedEntries = await service.GetByCondition<FeedArticleRelationEntity>(d => d.FeedGuid == stringGuid, null, false, 0, 0);
            var oldArticles = new List<ArticleModel>(model.AllArticles);


            for (int index = 0; index < newArticles.Count; index++)
            {
                var articleModel = newArticles[index];
                articleModel.Feed = model;

                var oldOne = oldArticles.FirstOrDefault(s => s.PublicUri == articleModel.PublicUri);
                if (oldOne == null)
                {
                    var oldFromDatabase = feedEntries.FirstOrDefault(s => articleModel.PublicUri == s.Url);
                    if (oldFromDatabase != null)
                    {
                        var article = await LoadHelper.LoadForFeed(oldFromDatabase.ArticleId, model, service, imageDownloadService);
                        feedEntries.Remove(oldFromDatabase);
                        oldFromDatabase.Index = index;
                        await service.Update(oldFromDatabase);

                        if (model.AllArticles.Count > index)
                            model.AllArticles[index] = article;
                        else
                            model.AllArticles.Add(article);
                    }
                    else
                    {
                        await SaveArticle(articleModel, service);
                        await SaveArticleLeadImage(articleModel, service, true);
                        await SaveArticleContent(articleModel, service, true);

                        var fe = new FeedArticleRelationEntity()
                        {
                            ArticleId = articleModel.GetId(),
                            Url = articleModel.PublicUri,
                            FeedGuid = model.Guid.ToString(),
                            Index = index
                        };
                        await service.Add(fe);

                        if (model.AllArticles.Count > index)
                            model.AllArticles[index] = articleModel;
                        else
                            model.AllArticles.Add(articleModel);
                    }
                }
                else
                {
                    if (model.AllArticles.Count > index)
                        model.AllArticles[index] = oldOne;
                    else
                        model.AllArticles.Add(oldOne);

                    var oldFromDatabase = feedEntries.FirstOrDefault(s => articleModel.PublicUri == s.Url);
                    if (oldFromDatabase != null)
                    {
                        oldFromDatabase.Index = index;
                        await service.Update(oldFromDatabase);
                    }
                    else
                    {
                        var fe = new FeedArticleRelationEntity()
                        {
                            ArticleId = oldOne.GetId(),
                            Url = oldOne.PublicUri,
                            FeedGuid = model.Guid.ToString(),
                            Index = index
                        };
                        await service.Add(fe);
                    }
                }
            }

            await service.DeleteAllById<FeedArticleRelationEntity>(feedEntries.Select(s => s.Id));
        }
Ejemplo n.º 32
0
 public PreferencesService(ISqliteService sqliteService)
 {
     _sqliteService = sqliteService;
 }
Ejemplo n.º 33
0
 public ItemRepository()
 {
     _sqliteService = DependencyService.Get <ISqliteService>();
 }
Ejemplo n.º 34
0
 public MainViewModel(ISqliteService sqliteService)
 {
     _sqliteService = sqliteService;
 }
Ejemplo n.º 35
0
 public GenericRepository(ISqliteService dataService, IExceptionLogger exceptionLogger = null)
 {
     _dataService     = dataService;
     _exceptionLogger = exceptionLogger;
 }
Ejemplo n.º 36
0
 public NfieldServer()
 {
     _sqliteService = DependencyService.Get <ISqliteService <ServerEntity> >();
 }