/// <summary>
        /// Uses the FileDataContext to retrieve records of registered user accounts. The calling class can
        /// just perform lambda expression to filter data.
        /// Since an Account record has a foreign key reference of Resident model, then this method also handles the assignment
        /// of the Resident record.
        /// </summary>
        /// <returns>List of Accounts model that contains the data in the text file.</returns>
        public List <Account> Accounts()
        {
            List <Account>  accounts  = new FileDataContext().ReadAccounts();
            List <Resident> residents = new FileDataContext().ReadResidents();

            List <Account> invalidAccounts = new List <Account>();

            foreach (var account in accounts)
            {
                // the account is invalid if the Account does not have Resident record, then we remove it from the list
                Resident userinfo = residents.Where(m => m.ResidentId == account.ResidentId).FirstOrDefault();
                if (userinfo != null)
                {
                    account.Resident = userinfo;
                }
                else
                {
                    invalidAccounts.Add(account);
                }
            }

            // delete invalid account
            foreach (var invalidAccount in invalidAccounts)
            {
                accounts.Remove(invalidAccount);
            }

            return(accounts);
        }
        /// <summary>
        /// Uses the FileDataContext to retrieve records of recorded summon reports. The calling class can
        /// just perform lambda expression to filter data.
        /// Since an Summon record has a foreign key reference of Account model, then this method also handles the assignment
        /// of the Account record.
        /// </summary>
        /// <returns>List of Resident model that contains the data in the text file.</returns>
        public List <Summon> Summons()
        {
            List <Summon>  summons  = new FileDataContext().ReadSummons();
            List <Account> accounts = new FileDataContext().ReadAccounts();

            List <Summon> invalidSummons = new List <Summon>();

            foreach (var summon in summons)
            {
                Account accountInfo = accounts.Where(m => m.AccountId == summon.AccountId).FirstOrDefault();
                if (accountInfo != null)
                {
                    summon.Account = accountInfo;
                }
                else
                {
                    invalidSummons.Add(summon);
                }
            }

            // delete
            foreach (var invalidSummon in invalidSummons)
            {
                summons.Remove(invalidSummon);
            }

            return(summons);
        }
Ejemplo n.º 3
0
 public FileUploadController(FileDataContext context, IHostingEnvironment hostingEnvironment, IFileService fileService, IAccountManagerService accountManagerService)
 {
     this.Context               = context;
     this.HostingEnvironment    = hostingEnvironment;
     this.FileService           = fileService;
     this.AccountManagerService = accountManagerService;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Uses the FileDataContext to retrieve records of families. The calling class can
        /// just perform lambda expression to filter data.
        /// Since a Family record has a foreign key reference of two Resident model, then this method also handles the assignment
        /// of the two Resident records.
        /// </summary>
        /// <returns>List of Family models that contains the data in the text file.</returns>
        public List <Family> Families()
        {
            List <Family>   families  = new FileDataContext().ReadFamilies();
            List <Resident> residents = new FileDataContext().ReadResidents();

            List <Family> invalidFamilies = new List <Family>();

            foreach (var family in families)
            {
                // A family may only have one parent
                Resident parentInfo = residents.Where(m => m.ResidentId == family.ParentOneId).FirstOrDefault();
                // if there is no parent one then skip the family record, and add to invalid families
                if (parentInfo != null)
                {
                    family.ParentOne = parentInfo;
                    parentInfo       = residents.Where(m => m.ResidentId == family.ParentTwoId).FirstOrDefault();

                    if (parentInfo != null)
                    {
                        family.ParentTwo = parentInfo;
                    }
                }
                else
                {
                    invalidFamilies.Add(family);
                }
            }

            // remove invalid families
            foreach (var invalidFamily in invalidFamilies)
            {
                families.Remove(invalidFamily);
            }
            return(families);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Uses the FileDataContext to retrieve records of recorded audit trails. The calling class can
        /// just perform lambda expression to filter data.
        /// Since a AuditTrail record has a foreign key reference of Account model, then this method also handles the assignment
        /// of the Account record.
        /// </summary>
        /// <returns>List of AuditTrail model that contains the data in the text file.</returns>
        public List <AuditTrail> AuditTrails()
        {
            List <AuditTrail> auditTrails = new FileDataContext().ReadAuditTrails();
            List <Account>    accounts    = new FileDataContext().ReadAccounts();

            List <AuditTrail> invalidAuditTrails = new List <AuditTrail>();

            foreach (var auditTrail in auditTrails)
            {
                Account accountInfo = accounts.Where(m => m.AccountId == auditTrail.AccountId).FirstOrDefault();
                if (accountInfo != null)
                {
                    auditTrail.Account = accountInfo;
                }
                else
                {
                    invalidAuditTrails.Add(auditTrail);
                }
            }

            // delete invalid audit trail
            foreach (var invalidAuditTrail in invalidAuditTrails)
            {
                auditTrails.Remove(invalidAuditTrail);
            }

            return(auditTrails);
        }
Ejemplo n.º 6
0
 public FileService(FileDataContext context, TicketDataContext ticketDataContext, ITicketBulkService <TicketVariableIncomeModel> ticketService, IHostingEnvironment hostingEnvironment)
 {
     this.Context            = context;
     this.TicketDataContext  = ticketDataContext;
     this.HostingEnvironment = hostingEnvironment;
     this.TicketService      = ticketService;
 }
        public void ShouldWriteHelpMessage()
        {
            var fileDataContext = new FileDataContext(new string[2] {
                "-z", "c:/test"
            });
            var stringWriter = new StringWriter();

            fileDataContext.Write(stringWriter);

            Assert.That(stringWriter.ToString().Contains(FileDataContext.HelpMessage));
        }
        public void ShouldWriteSize()
        {
            const int size        = 100000;
            var       filePath    = "c:/test";
            var       fileDetails = new Mock <IFileDetails>(MockBehavior.Strict);

            fileDetails.Setup(p => p.Size(filePath)).Returns(size);
            var fileDataContext = new FileDataContext(new string[2] {
                "-s", filePath
            }, new FileDataOptionSet(), fileDetails.Object);
            var stringWriter = new StringWriter();

            fileDataContext.Write(stringWriter);

            Assert.AreEqual(size.ToString(), stringWriter.ToString());
            fileDetails.VerifyAll();
        }
        public void ShouldWriteVersion()
        {
            const string version     = "EXPECTED_VERSION";
            var          filePath    = "c:/test";
            var          fileDetails = new Mock <IFileDetails>(MockBehavior.Strict);

            fileDetails.Setup(p => p.Version(filePath)).Returns(version);
            var fileDataContext = new FileDataContext(new string[2] {
                "-v", filePath
            }, new FileDataOptionSet(), fileDetails.Object);
            var stringWriter = new StringWriter();

            fileDataContext.Write(stringWriter);

            Assert.AreEqual(version, stringWriter.ToString());
            fileDetails.VerifyAll();
        }
Ejemplo n.º 10
0
 public FileManager(FileDataContext context)
 {
     _context = context;
 }
Ejemplo n.º 11
0
 public FileHashRepository(IMapper mapper, FileDataContext fileDataContext)
 {
     _mapper          = mapper;
     _fileDataContext = fileDataContext;
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Uses the FileDataContext to retrieve records of registered residents. The calling class can
        /// just perform lambda expression to filter data.
        /// </summary>
        /// <returns>List of Resident model that contains the data in the text file.</returns>
        public List <Resident> Residents()
        {
            List <Resident> residents = new FileDataContext().ReadResidents();

            return(residents);
        }
Ejemplo n.º 13
0
        private void Application_Startup(object sender, StartupEventArgs e)
        {
            //Récupère le language par défaut du support de l'utilisateur
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            ServiceCollection serviceCollection = new ServiceCollection();

            //Création du contexte de données de l'application.
            serviceCollection.AddSingleton <IDataContext, MoviesLibraryContext>(sp => FileDataContext.Load(this._FilePath, new MoviesLibraryContext(this._FilePath)));

            //Création des vue-modèle.
            serviceCollection.AddTransient <IViewModelMain, ViewModelMain>(sp => new ViewModelMain(sp));
            serviceCollection.AddTransient <IViewModelMovies, ViewModelSearchMovies>(sp => new ViewModelSearchMovies(sp));
            serviceCollection.AddTransient <IViewModelMyMovies, ViewModelMyMovies>(sp => new ViewModelMyMovies(sp.GetService <IDataContext>()));

            //Construction du fournisseur de service à partir de la définition des services disponibles.
            ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();

            //Création de l'instance de la fenêtre principale.
            MainWindow window = new MainWindow();

            //Injection du vue-modèle de la fenêtre.
            window.DataContext = serviceProvider.GetService <IViewModelMain>();
            //Affichage de la fenêtre principale.
            window.Show();
        }