Ejemplo n.º 1
0
 public UnitOfWork(DataContext context)
 {
     _context      = context;
     Tutorials     = new TutorialRepository(_context);
     Users         = new UserRepository(_context);
     Languages     = new LanguageRepository(_context);
     TutorialSteps = new TutorialStepRepository(_context);
     Steps         = new StepRepository(_context);
 }
        public static async Task Run([CosmosDBTrigger(
                                          databaseName: "Moneybox",
                                          collectionName: "Users",
                                          ConnectionStringSetting = "CosmosDBConnection",
                                          LeaseCollectionName = "leases",
                                          CreateLeaseCollectionIfNotExists = true)] IReadOnlyList <Document> input,
                                     [CosmosDB(
                                          databaseName: "Moneybox",
                                          collectionName: "Tutorials",
                                          ConnectionStringSetting = "CosmosDBConnection",
                                          CreateIfNotExists = true)] DocumentClient tutorialsClient,
                                     [CosmosDB(
                                          databaseName: "Moneybox",
                                          collectionName: "TutorialTips",
                                          ConnectionStringSetting = "CosmosDBConnection",
                                          CreateIfNotExists = true)] DocumentClient tutorialTipsClient,
                                     ILogger log)
        {
            if (input != null && input.Count > 0)
            {
                ITutorialRepository    tutorialRepository    = new TutorialRepository(tutorialsClient);
                ITutorialTipRepository tutorialTipRepository = new TutorialTipRepository(tutorialTipsClient);

                var tutorialTips = await tutorialTipRepository.GetAll();

                foreach (var id in input.Select(d => d.Id))
                {
                    var existingTutorial = await tutorialRepository.FindTutorial(id);

                    if (existingTutorial == null)
                    {
                        var tutorial = new Tutorial(id);
                        tutorial.SyncTutorialTips(tutorialTips.ToArray());

                        await tutorialRepository.UpsertTutorial(tutorial);
                    }
                }
            }
        }
 public EfCoreController(TutorialRepository repository)
 {
     this.Repository = repository;
 }
 private void OnEnable()
 {
     instance = this;
     items    = GetComponentsInChildren <TutorialRepositoryItem>();
 }
Ejemplo n.º 5
0
 public HomeController()
 {
     _repo = new TutorialRepository();
 }