public ActionResult Politician(int id = 0)
        {
            if (id == 0)
            {
                return(View(new PersonDto()));
            }

            var personRepo = new PersonRepository();
            var person     = personRepo.Get(id);

            var personDto = PersonMapper.MapPerson(person);

            var languageManager = new LanguageManager();

            personDto = languageManager.GetTranslations(personDto);
            return(View(personDto));
        }
        public ActionResult DeleteTrack(int politicianId, int trackId)
        {
            var personRepo      = new PersonRepository();
            var languageManager = new LanguageManager();

            var deletedTrack = personRepo.GetTrack(politicianId, trackId);

            personRepo.DeleteTrack(politicianId, trackId);

            ViewBag.Notifications = $"Track {deletedTrack.Name} deleted.";

            var person = personRepo.Get(politicianId);

            var personDto = PersonMapper.MapPerson(person);

            personDto = languageManager.GetTranslations(personDto);

            return(View("Politician", personDto));
        }
Exemplo n.º 3
0
        public void PushtoDatabase(int columns, int rows, Worksheet worksheet)
        {
            Dictionary <string, int> columnNamesWithIndex = new Dictionary <string, int>();

            for (int i = 1; i <= columns; i++)
            {
                columnNamesWithIndex.Add(worksheet.Cells[i][1].Value.ToString(), i);
            }

            var addressMapper            = new AddressMapper();
            var addressRepository        = new AddressRepository();
            var personMapper             = new PersonMapper();
            var personRepository         = new PersonRepository();
            var financialStateMapper     = new FinancialStateMapper();
            var financialStateRepository = new FinancialStateRepository();
            var agrementMapper           = new AgreementMapper();
            var agreementRepository      = new AgreementRepository();
            var peselVerifier            = new PeselVerifier();

            for (int i = 2; i <= rows; i++)
            {
                var addressObject = addressMapper.MapAdress(worksheet, i, columnNamesWithIndex);
                var addressId     = addressRepository.PushAddressesToDb(addressObject);

                var personObject = personMapper.MapPerson(worksheet, i, columnNamesWithIndex, addressId);
                var validPesel   = peselVerifier.VerifyPesel(personObject.NationalIdentificationNumber);
                // validPesel -tutaj mam wartosc true albo false dla kazdego z peseli
                // dla ktorego robie walidacje w osobnej metodzie

                var personId = personRepository.PushPeopleToDb(personObject);

                var financialStateObject = financialStateMapper.MapFinancialState(worksheet, i, columnNamesWithIndex);
                var financialStateId     = financialStateRepository.PushFinancialStatesToDb(financialStateObject);

                var agreementObject = agrementMapper.MapAgreement(worksheet, i, columnNamesWithIndex, personId, financialStateId);
                agreementRepository.PushAgreementsToDb(agreementObject);
            }
        }