예제 #1
0
        public void BindDDLs(PlaceView placeView, ObjectContext db)
        {
            //countries ddl
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            placeView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");

            //counties ddl
            if (placeView.CountryFK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                placeView.Counties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(placeView.CountryFK)).OrderBy("Name ASC"), "CountyPK", "Name");
            }
            else
            {
                placeView.Counties = new SelectList(new List <County>(), "CountyPK", "Name");
            }

            //postal offices ddl
            if (placeView.CountyFK != null)
            {
                IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db);
                var postalOffices = postalOfficesRepository.GetValidByCounty(Convert.ToInt32(placeView.CountyFK)).OrderBy(c => c.Name);

                placeView.PostalOffices = new SelectList(postalOffices.Select(c => new { value = c.PostalOfficePK, text = c.Name + " (" + SqlFunctions.StringConvert((double)c.Number).Trim() + ")" }), "value", "text");
            }
            else
            {
                placeView.PostalOffices = new SelectList(new List <PostalOffice>(), "PostalOfficePK", "Name");
            }
        }
예제 #2
0
        public ActionResult Index()
        {
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            int    page       = !String.IsNullOrWhiteSpace(Request.QueryString["page"]) ? Convert.ToInt32(Request.QueryString["page"]) : 1;
            int    pageSize   = !String.IsNullOrWhiteSpace(Request.QueryString["pageSize"]) ? Convert.ToInt32(Request.QueryString["pageSize"]) : Convert.ToInt32(System.Configuration.ConfigurationManager.AppSettings["ResultsPerPage"]);
            string sortOrder  = !String.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC";
            string sortColumn = !String.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "CountryPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <Country> countries = countriesRepository.GetValid()
                                             .OrderBy(ordering);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                countries = countries.Where(c => c.Name.Contains(searchString) || c.NameEn.Contains(searchString) || c.Citizenship.Contains(searchString));
            }

            countries = countries.Page(page, pageSize);

            ViewData["numberOfRecords"] = countriesRepository.GetValid().Count();

            int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize;

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("Country?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", countries.ToList()));
            }
        }
예제 #3
0
        public void BindDDLs(LegalEntityBranchView legalEntityBranchView, ObjectContext db)
        {
            //countries ddl
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            legalEntityBranchView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");

            //counties ddl
            ICountiesRepository countiesRepository = new CountiesRepository(db);

            legalEntityBranchView.Counties = new SelectList(countiesRepository.GetCountiesByCountry((int)legalEntityBranchView.CountryFK).OrderBy("Name ASC").ToList(), "CountyPK", "Name");

            //citiesCommunities dll
            if (legalEntityBranchView.CountyFK != null)
            {
                ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);
                legalEntityBranchView.CitiesCommunities = new SelectList(citiesCommunitiesRepository.GetCitiesCommunitiesByCounty(Convert.ToInt32(legalEntityBranchView.CountyFK)).OrderBy("Name ASC"), "CityCommunityPK", "Name", legalEntityBranchView.CityCommunityFK);
            }
            else
            {
                legalEntityBranchView.CitiesCommunities = new SelectList(new List <CityCommunity>(), "CityCommunityPK", "Name");
            }

            //postal offices dll
            if (legalEntityBranchView.CountyFK != null)
            {
                IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db);
                legalEntityBranchView.PostalOffices = new SelectList(postalOfficesRepository.GetValidByCounty(Convert.ToInt32(legalEntityBranchView.CountyFK)).OrderBy("Name ASC"), "PostalOfficePK", "Name", legalEntityBranchView.PostalOfficeFK);
            }
            else
            {
                legalEntityBranchView.PostalOffices = new SelectList(new List <PostalOffice>(), "PostalOfficePK", "Name");
            }

            //places dll
            if (legalEntityBranchView.PostalOfficeFK != null)
            {
                IPlacesRepository placesRepository = new PlacesRepository(db);
                legalEntityBranchView.Places = new SelectList(placesRepository.GetPlacesByPostalOffice(Convert.ToInt32(legalEntityBranchView.PostalOfficeFK)).OrderBy("Name ASC"), "PlacePK", "Name", legalEntityBranchView.PlaceFK);
            }
            else
            {
                legalEntityBranchView.Places = new SelectList(new List <Place>(), "PlacePK", "Name");
            }
        }
예제 #4
0
        public void BindDDLs(CityCommunityView cityCommunityView, ObjectContext db)
        {
            //countries ddl
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            cityCommunityView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");

            //counties ddl
            if (cityCommunityView.CountryFK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                cityCommunityView.Counties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32((int)cityCommunityView.CountryFK)).OrderBy("Name ASC"), "CountyPK", "Name");
            }
            else
            {
                cityCommunityView.Counties = new SelectList(new List <County>(), "CountyPK", "Name");
            }
        }
예제 #5
0
        public static List <LegalEntityBranchAuditView> GetLegalEntityBranchAuditView(ObjectContext context, int relatedEntityPK)
        {
            IAuditingDetailsRepository auditingDetailsRepository = new AuditingDetailsRepository(context);
            IAuditingMasterRepository  auditingMasterRepository  = new AuditingMasterRepository(context);

            var sessionTokens = (from am in auditingMasterRepository.GetAll().Where(c => c.TableName == "LegalEntityBranches")
                                 where am.RelatedEntityPK == relatedEntityPK
                                 select new {
                AuditingMasterPK = am.AuditingMasterPK,
                RelatedEntityPK = am.RelatedEntityPK,
                SessionToken = am.SessionToken
            }).ToList();

            List <LegalEntityBranchAuditView> legalEntityLegalEntityBranchAuditViewList = new List <LegalEntityBranchAuditView>();

            foreach (var item in sessionTokens)
            {
                var record = auditingDetailsRepository.GetAuditingDetailByAuditingMasterPK(item.AuditingMasterPK).ToList();

                LegalEntityBranchAuditView legalEntityLegalEntityBranchAuditView = new LegalEntityBranchAuditView();

                legalEntityLegalEntityBranchAuditView.Name = record.checkString("Name");

                legalEntityLegalEntityBranchAuditView.CountryFK       = record.checkInteger("CountryFK");
                legalEntityLegalEntityBranchAuditView.CountyFK        = record.checkInteger("CountyFK");
                legalEntityLegalEntityBranchAuditView.CityCommunityFK = record.checkInteger("CityCommunityFK");
                legalEntityLegalEntityBranchAuditView.PostalOfficeFK  = record.checkInteger("PostalOfficeFK");
                legalEntityLegalEntityBranchAuditView.PlaceFK         = record.checkInteger("PlaceFK");
                legalEntityLegalEntityBranchAuditView.StreetName      = record.checkString("StreetName");

                legalEntityLegalEntityBranchAuditView.Phone  = record.checkString("Phone");
                legalEntityLegalEntityBranchAuditView.Fax    = record.checkString("Fax");
                legalEntityLegalEntityBranchAuditView.Mobile = record.checkString("Mobile");
                legalEntityLegalEntityBranchAuditView.EMail  = record.checkString("EMail");

                legalEntityLegalEntityBranchAuditView.ChangeDate = record.checkDate("ChangeDate");
                legalEntityLegalEntityBranchAuditView.Deleted    = record.checkBoolean("Deleted");

                legalEntityLegalEntityBranchAuditViewList.Add(legalEntityLegalEntityBranchAuditView);
            }

            ICountriesRepository countriesRepository = new CountriesRepository(context);
            IQueryable <Country> countriesTable      = countriesRepository.GetValid();

            ICountiesRepository countiesRepository = new CountiesRepository(context);
            IQueryable <County> countiesTable      = countiesRepository.GetValid();

            ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(context);
            IQueryable <CityCommunity>   citiesCommunitiesTable      = citiesCommunitiesRepository.GetValid();

            IPlacesRepository  placesRepository = new PlacesRepository(context);
            IQueryable <Place> placesTable      = placesRepository.GetValid();

            IPostalOfficesRepository  postalOfficesRepository = new PostalOfficesRepository(context);
            IQueryable <PostalOffice> postalOfficesTable      = postalOfficesRepository.GetValid();

            List <LegalEntityBranchAuditView> legalEntityLegalEntityBranch =
                (from t in legalEntityLegalEntityBranchAuditViewList
                 from t1 in countriesTable.Where(tbl => tbl.CountryPK == t.CountryFK).DefaultIfEmpty()
                 from t2 in countiesTable.Where(tbl => tbl.CountyPK == t.CountyFK).DefaultIfEmpty()
                 from t3 in citiesCommunitiesTable.Where(tbl => tbl.CityCommunityPK == t.CityCommunityFK).DefaultIfEmpty()
                 from t4 in placesTable.Where(tbl => tbl.PlacePK == t.PlaceFK).DefaultIfEmpty()
                 from t5 in postalOfficesTable.Where(tbl => tbl.PostalOfficePK == t.PostalOfficeFK).DefaultIfEmpty()
                 where t.ChangeDate != null
                 select new LegalEntityBranchAuditView
            {
                LegalEntityBranchPK = t.LegalEntityBranchPK,
                Name = t.Name,

                CountryName = t1 != null && t1.Name != null ? t1.Name : null,
                CountyName = t2 != null && t2.Name != null ? t2.Name : null,
                CityCommunityName = t3 != null && t3.Name != null ? t3.Name : null,
                PlaceName = t4 != null && t4.Name != null ? t4.Name : null,
                PostalOfficeName = t5 != null && t5.Name != null ? t5.Name : null,
                StreetName = t.StreetName != null ? t.StreetName : null,

                Phone = t.Phone != null ? t.Phone : null,
                Fax = t.Fax != null ? t.Fax : null,
                Mobile = t.Mobile != null ? t.Mobile : null,
                EMail = t.EMail != null ? t.EMail : null,

                ChangeDate = t.ChangeDate != null ? t.ChangeDate : null,
                Deleted = t.Deleted != null ? t.Deleted : null,
            }).OrderBy(c => c.ChangeDate).ToList();

            return(legalEntityLegalEntityBranch);
        }
예제 #6
0
        public static List <PhysicalEntityAuditView> GetPhysicalEntityAuditView(ObjectContext context, int relatedEntityPK)
        {
            IAuditingDetailsRepository auditingDetailsRepository = new AuditingDetailsRepository(context);
            IAuditingMasterRepository  auditingMasterRepository  = new AuditingMasterRepository(context);

            List <PhysicalEntityAuditView> physicalEntityAuditViewList = new List <PhysicalEntityAuditView>();

            var sessionTokens = (from am in auditingMasterRepository.GetAll().Where(c => c.TableName == "PhysicalEntities")
                                 where am.RelatedEntityPK == relatedEntityPK
                                 select new {
                auditingMasterPK = am.AuditingMasterPK,
                sessionToken = am.SessionToken
            }).ToList();

            foreach (var item in sessionTokens)
            {
                List <AuditingDetail> record = auditingDetailsRepository.GetAuditingDetailByAuditingMasterPK(item.auditingMasterPK).ToList();

                PhysicalEntityAuditView peav = new PhysicalEntityAuditView();

                peav.Firstname = record.checkString("Firstname");
                peav.Lastname  = record.checkString("Lastname");

                peav.Gender = record.checkString("Gender");

                peav.OIB  = record.checkString("OIB");
                peav.JMBG = record.checkString("JMBG");

                peav.DateOfBirth = record.checkDate("DateOfBirth");

                peav.CitizenshipFK        = record.checkInteger("CitizenshipFK");
                peav.BirthCountryFK       = record.checkInteger("BirthCountryFK");
                peav.BirthCountyFK        = record.checkInteger("BirthCountyFK");
                peav.BirthCityCommunityFK = record.checkInteger("BirthCityCommunityFK");
                peav.BirthPlace           = record.checkString("BirthPlace");

                peav.ResidenceCountryFK       = record.checkInteger("ResidenceCountryFK");
                peav.ResidenceCountyFK        = record.checkInteger("ResidenceCountyFK");
                peav.ResidenceCityCommunityFK = record.checkInteger("ResidenceCityCommunityFK");
                peav.ResidencePostalOfficeFK  = record.checkInteger("ResidencePostalOfficeFK");
                peav.ResidencePlaceFK         = record.checkInteger("ResidencePlaceFK");
                peav.ResidencePlace           = record.checkString("ResidencePlace");
                peav.ResidenceStreetName      = record.checkString("ResidenceStreetName");

                peav.IdentityCardNumber           = record.checkString("IdentityCardNumber");
                peav.IdentityCardDateOfIssue      = record.checkDate("IdentityCardDateOfIssue");
                peav.IdentityCardRegionalOfficeFK = record.checkInteger("IdentityCardRegionalOfficeFK");
                peav.IdentityCardDateTillValid    = record.checkDate("IdentityCardDateTillValid");

                peav.PassportNumber           = record.checkString("PassportNumber");
                peav.PassportDateOfIssue      = record.checkDate("PassportDateOfIssue");
                peav.PassportDateTillValid    = record.checkDate("PassportDateTillValid");
                peav.PassportCountryOfIssueFK = record.checkInteger("PassportCountryOfIssueFK");
                peav.PassportPlaceOfIssue     = record.checkString("PassportPlaceOfIssue");

                peav.ReferentRegionalOfficeFK = record.checkInteger("ReferentRegionalOfficeFK");
                peav.ReferentSubstationFK     = record.checkInteger("ReferentSubstationFK");

                peav.ChangeDate = record.checkDate("ChangeDate");

                peav.LegalRepresentative = record.checkBoolean("LegalRepresentative");
                peav.Owner    = record.checkBoolean("Owner");
                peav.Referent = record.checkBoolean("Referent");

                physicalEntityAuditViewList.Add(peav);
            }

            // Connect all foreign keys and return data collection as List<PhysicalEntityAuditView>
            ICountriesRepository countriesRepository = new CountriesRepository(context);
            IQueryable <Country> countryTable        = countriesRepository.GetValid();

            ICountiesRepository countiesRepository = new CountiesRepository(context);
            IQueryable <County> countyTable        = countiesRepository.GetValid();

            ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(context);
            IQueryable <CityCommunity>   cityCommunityTable          = citiesCommunitiesRepository.GetValid();

            IPostalOfficesRepository  postalOfficesRepository = new PostalOfficesRepository(context);
            IQueryable <PostalOffice> postalOfficeTable       = postalOfficesRepository.GetValid();

            IPlacesRepository  placesRepository = new PlacesRepository(context);
            IQueryable <Place> placeTable       = placesRepository.GetValid();

            IRegionalOfficesRepository  regionalOfficesRepository = new RegionalOfficesRepository(context);
            IQueryable <RegionalOffice> regionalOfficeTable       = regionalOfficesRepository.GetValid();

            ISubstationsRepository  substationsRepository = new SubstationsRepository(context);
            IQueryable <Substation> substationTable       = substationsRepository.GetValid();

            List <PhysicalEntityAuditView> physicalEntityAuditView =
                (from t in physicalEntityAuditViewList

                 from t1 in countryTable.Where(tbl => tbl.CountryPK == t.CitizenshipFK).DefaultIfEmpty()
                 from t2 in countryTable.Where(tbl => tbl.CountryPK == t.CitizenshipFK).DefaultIfEmpty()
                 from t3 in countyTable.Where(tbl => tbl.CountyPK == t.BirthCountyFK).DefaultIfEmpty()
                 from t4 in cityCommunityTable.Where(tbl => tbl.CityCommunityPK == t.BirthCityCommunityFK).DefaultIfEmpty()

                 from t5 in countryTable.Where(tbl => tbl.CountryPK == t.ResidenceCountryFK).DefaultIfEmpty()
                 from t6 in countyTable.Where(tbl => tbl.CountyPK == t.ResidenceCountyFK).DefaultIfEmpty()
                 from t7 in cityCommunityTable.Where(tbl => tbl.CityCommunityPK == t.ResidenceCityCommunityFK).DefaultIfEmpty()
                 from t8 in postalOfficeTable.Where(tbl => tbl.PostalOfficePK == t.ResidencePostalOfficeFK).DefaultIfEmpty()
                 from t9 in placeTable.Where(tbl => tbl.PlacePK == t.ResidencePlaceFK).DefaultIfEmpty()

                 from t10 in countryTable.Where(tbl => tbl.CountryPK == t.PassportCountryOfIssueFK).DefaultIfEmpty()
                 from t11 in regionalOfficeTable.Where(tbl => tbl.RegionalOfficePK == t.IdentityCardRegionalOfficeFK).DefaultIfEmpty()

                 from t12 in regionalOfficeTable.Where(tbl => tbl.RegionalOfficePK == t.ReferentRegionalOfficeFK).DefaultIfEmpty()
                 from t13 in substationTable.Where(tbl => tbl.SubstationPK == t.ReferentSubstationFK).DefaultIfEmpty()
                 select new PhysicalEntityAuditView
            {
                PhysicalEntityPK = t.PhysicalEntityPK,
                Firstname = t.Firstname != null ? t.Firstname : null,
                Lastname = t.Lastname != null ? t.Lastname : null,

                Gender = t.Gender != null ? t.Gender : null,
                OIB = t.OIB != null ? t.OIB : null,
                JMBG = t.JMBG != null ? t.JMBG : null,

                DateOfBirth = t.DateOfBirth != null ? t.DateOfBirth : null,

                CitizenshipFK = t.CitizenshipFK != null ? t.CitizenshipFK : null,
                BirthCountryFK = t.BirthCountryFK != null ? t.BirthCountryFK : null,
                BirthCountyFK = t.BirthCountyFK != null ? t.BirthCountyFK : null,
                BirthCityCommunityFK = t.BirthCityCommunityFK != null ? t.BirthCityCommunityFK : null,
                BirthPlace = t.BirthPlace != null ? t.BirthPlace : null,

                ResidenceCountryFK = t.ResidenceCountryFK != null ? t.ResidenceCountryFK : null,
                ResidenceCountyFK = t.ResidenceCountyFK != null ? t.ResidenceCountyFK : null,
                ResidenceCityCommunityFK = t.ResidenceCityCommunityFK != null ? t.ResidenceCityCommunityFK : null,
                ResidencePostalOfficeFK = t.ResidencePostalOfficeFK != null ? t.ResidencePostalOfficeFK : null,
                ResidencePlaceFK = t.ResidencePlaceFK != null ? t.ResidencePlaceFK : null,
                ResidencePlace = t.ResidencePlace != null ? t.ResidencePlace : null,
                ResidenceStreetName = t.ResidenceStreetName != null ? t.ResidenceStreetName : null,

                IdentityCardNumber = t.IdentityCardNumber != null ? t.IdentityCardNumber : null,
                IdentityCardDateOfIssue = t.IdentityCardDateOfIssue != null ? t.IdentityCardDateOfIssue : null,
                IdentityCardRegionalOfficeFK = t.IdentityCardRegionalOfficeFK != null ? t.IdentityCardRegionalOfficeFK : null,
                IdentityCardDateTillValid = t.IdentityCardDateTillValid != null ? t.IdentityCardDateTillValid : null,

                PassportNumber = t.PassportNumber != null ? t.PassportNumber : null,
                PassportDateOfIssue = t.PassportDateOfIssue != null ? t.PassportDateOfIssue : null,
                PassportDateTillValid = t.PassportDateTillValid != null ? t.PassportDateTillValid : null,
                PassportCountryOfIssueFK = t.PassportCountryOfIssueFK != null ? t.PassportCountryOfIssueFK : null,
                PassportPlaceOfIssue = t.PassportPlaceOfIssue != null ? t.PassportPlaceOfIssue : null,

                ReferentRegionalOfficeFK = t.ReferentRegionalOfficeFK != null ? t.ReferentRegionalOfficeFK : null,
                ReferentSubstationFK = t.ReferentSubstationFK != null ? t.ReferentSubstationFK : null,

                ChangeDate = t.ChangeDate != null ? t.ChangeDate : null,

                LegalRepresentative = t.LegalRepresentative != null ? t.LegalRepresentative : null,
                Owner = t.Owner != null ? t.Owner : null,
                Referent = t.Referent != null ? t.Referent : null,

                Deleted = t.Deleted != null ? t.Deleted : null,

                Citizenship = t1 != null && t1.Citizenship != null ? t1.Citizenship : null,
                BirthCountryName = t2 != null && t2.Name != null ? t2.Name : null,
                BirthCountyName = t3 != null && t3.Name != null ? t3.Name : null,
                BirthCityCommunityName = t4 != null && t4.Name != null ? t4.Name : null,

                ResidenceCountryName = t5 != null && t5.Name != null ? t5.Name : null,
                ResidenceCountyName = t6 != null && t6.Name != null ? t6.Name : null,
                ResidenceCityCommunityName = t7 != null && t7.Name != null ? t7.Name : null,
                ResidencePostalOfficeName = t8 != null && t8.Name != null ? t8.Name : null,
                ResidencePlaceName = t9 != null && t9.Name != null ? t9.Name : null,

                PassportCountryOfIssueName = t10 != null && t10.Name != null ? t10.Name : null,
                IdentityCardRegionalOfficeName = t11 != null && t11.Name != null ? t11.Name : null,

                ReferentRegionalOfficeName = t12 != null && t12.Name != null ? t12.Name : null,
                ReferentSubstationName = t13 != null && t13.Name != null ? t13.Name : null,
            }).OrderBy(c => c.ChangeDate).ToList();

            return(physicalEntityAuditView);
        }
예제 #7
0
        public void BindDDLs(PhysicalEntityView physicalEntityView, ObjectContext db)
        {
            //countries ddl
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            physicalEntityView.Citizenships             = new SelectList(countriesRepository.GetCitizenships().ToList(), "CountryPK", "Citizenship");
            physicalEntityView.BirthCountries           = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");
            physicalEntityView.ResidenceCountries       = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");
            physicalEntityView.PassportCountriesOfIssue = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");

            //counties ddl
            if (physicalEntityView.BirthCountryFK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                physicalEntityView.BirthCounties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(physicalEntityView.BirthCountryFK)), "CountyPK", "Name", physicalEntityView.BirthCountyFK);
            }
            else
            {
                physicalEntityView.BirthCounties = new SelectList(new List <County>(), "CountyPK", "Name");
            }

            if (physicalEntityView.ResidenceCountryFK != null)
            {
                ICountiesRepository countiesRepository = new CountiesRepository(db);
                physicalEntityView.ResidenceCounties = new SelectList(countiesRepository.GetCountiesByCountry(Convert.ToInt32(physicalEntityView.ResidenceCountryFK)), "CountyPK", "Name", physicalEntityView.ResidenceCountyFK);
            }
            else
            {
                physicalEntityView.ResidenceCounties = new SelectList(new List <County>(), "CountyPK", "Name");
            }

            //citiesCommunities ddl
            if (physicalEntityView.BirthCountyFK != null)
            {
                ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);
                physicalEntityView.BirthCitiesCommunities = new SelectList(citiesCommunitiesRepository.GetCitiesCommunitiesByCounty(Convert.ToInt32(physicalEntityView.BirthCountyFK)), "CityCommunityPK", "Name", physicalEntityView.BirthCityCommunityFK);
            }
            else
            {
                physicalEntityView.BirthCitiesCommunities = new SelectList(new List <CityCommunity>(), "CityCommunityPK", "Name");
            }

            if (physicalEntityView.ResidenceCountyFK != null)
            {
                ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(db);
                physicalEntityView.ResidenceCitiesCommunities = new SelectList(citiesCommunitiesRepository.GetCitiesCommunitiesByCounty(Convert.ToInt32(physicalEntityView.ResidenceCountyFK)), "CityCommunityPK", "Name", physicalEntityView.ResidenceCityCommunityFK);
            }
            else
            {
                physicalEntityView.ResidenceCitiesCommunities = new SelectList(new List <CityCommunity>(), "CityCommunityPK", "Name");
            }

            //postal offices
            if (physicalEntityView.ResidenceCountyFK != null)
            {
                IPostalOfficesRepository postalOfficesRepository = new PostalOfficesRepository(db);
                var postalOffices = postalOfficesRepository.GetValidByCounty(Convert.ToInt32(physicalEntityView.ResidenceCountyFK)).OrderBy(c => c.Name);

                physicalEntityView.ResidencePostalOffices = new SelectList(postalOffices.Select(c => new { value = c.PostalOfficePK, text = c.Name + " (" + SqlFunctions.StringConvert((double)c.Number).Trim() + ")" }), "value", "text", physicalEntityView.ResidencePostalOfficeFK);
            }
            else
            {
                physicalEntityView.ResidencePostalOffices = new SelectList(new List <PostalOffice>(), "PostalOfficePK", "Name");
            }

            //places
            if (physicalEntityView.ResidencePostalOfficeFK != null)
            {
                IPlacesRepository placesRepository = new PlacesRepository(db);
                physicalEntityView.ResidencePlaces = new SelectList(placesRepository.GetPlacesByPostalOffice(Convert.ToInt32(physicalEntityView.ResidencePostalOfficeFK)), "PlacePK", "Name", physicalEntityView.ResidencePlaceFK);
            }
            else
            {
                physicalEntityView.ResidencePlaces = new SelectList(new List <Place>(), "PlacePK", "Name");
            }

            //regional offices ddl
            IRegionalOfficesRepository regionalOfficesView = new RegionalOfficesRepository(db);

            physicalEntityView.IdentityCardRegionalOffices = new SelectList(regionalOfficesView.GetValid().ToList(), "RegionalOfficePK", "Name", physicalEntityView.IdentityCardRegionalOfficeFK);
            physicalEntityView.ReferentRegionalOffices     = new SelectList(regionalOfficesView.GetValid().ToList(), "RegionalOfficePK", "Name", physicalEntityView.ReferentRegionalOfficeFK);

            //substations
            if (physicalEntityView.ReferentRegionalOfficeFK != null)
            {
                ISubstationsRepository substationsRepository = new SubstationsRepository(db);
                physicalEntityView.ReferentSubstations = new SelectList(substationsRepository.GetValidByRegionalOffice(Convert.ToInt32(physicalEntityView.ReferentRegionalOfficeFK)), "SubstationPK", "Name", physicalEntityView.ReferentSubstationFK);
            }
            else
            {
                physicalEntityView.ReferentSubstations = new SelectList(new List <Place>(), "SubstationPK", "Name");
            }

            // genders dll
            physicalEntityView.Genders = new SelectList(GeneratorView.GenerateGenders(), "Value", "Text");
        }
예제 #8
0
        public static List <LegalEntityAuditView> GetLegalEntityAuditView(ObjectContext context, int relatedEntityPK)
        {
            IAuditingDetailsRepository auditingDetailsRepository = new AuditingDetailsRepository(context);
            IAuditingMasterRepository  auditingMasterRepository  = new AuditingMasterRepository(context);

            List <LegalEntityAuditView> legalEntityAuditViewList = new List <LegalEntityAuditView>();

            var sessionTokens = (from am in auditingMasterRepository.GetAll().Where(c => c.TableName == "LegalEntities")
                                 where am.RelatedEntityPK == relatedEntityPK
                                 select new {
                auditingMasterPK = am.AuditingMasterPK,
                sessionToken = am.SessionToken
            }).ToList();

            foreach (var item in sessionTokens)
            {
                var record = auditingDetailsRepository.GetAuditingDetailByAuditingMasterPK(item.auditingMasterPK).ToList();

                LegalEntityAuditView leav = new LegalEntityAuditView();

                leav.Name                = record.checkString("Name");
                leav.ShortName           = record.checkString("ShortName");
                leav.OIB                 = record.checkString("OIB");
                leav.MB                  = record.checkString("MB");
                leav.MBS                 = record.checkString("MBS");
                leav.ActivityFK          = record.checkInteger("ActivityFK");
                leav.ActivityDescription = record.checkString("ActivityDescription");
                leav.FormFK              = record.checkInteger("FormFK");
                leav.FundamentalCapital  = record.checkDecimal("FundamentalCapital");

                leav.CountryFK       = record.checkInteger("CountryFK");
                leav.CountyFK        = record.checkInteger("CountyFK");
                leav.PlaceFK         = record.checkInteger("PlaceFK");
                leav.PostalOfficeFK  = record.checkInteger("PostalOfficeFK");
                leav.Place           = record.checkString("Place");
                leav.CityCommunityFK = record.checkInteger("CityCommunityFK");
                leav.StreetName      = record.checkString("StreetName");

                leav.RegionalOfficeFK   = record.checkInteger("RegionalOfficeFK");
                leav.SubstationFK       = record.checkInteger("SubstationFK");
                leav.ReferentFK         = record.checkInteger("ReferentFK");
                leav.DateOfRegistration = record.checkDate("DateOfRegistration");
                leav.CommercialCourtFK  = record.checkInteger("CommercialCourtFK");
                leav.TaxFK = record.checkInteger("TaxFK");

                leav.Phone  = record.checkString("Phone");
                leav.Fax    = record.checkString("Fax");
                leav.Mobile = record.checkString("Mobile");
                leav.EMail  = record.checkString("EMail");

                leav.FirstContactDate           = record.checkDate("FirstContactDate");
                leav.TouristOffice              = record.checkBoolean("TouristOffice");
                leav.TouristOfficeDescription   = record.checkString("TouristOfficeDescription");
                leav.MonumentAnnuity            = record.checkBoolean("MonumentAnnuity");
                leav.MonumentAnnuityDescription = record.checkString("MonumentAnnuityDescription");
                leav.NumberOfEmployees          = record.checkInteger("NumberOfEmployees");
                leav.MIORRegistrationNumber     = record.checkString("MIORRegistrationNumber");
                leav.HZZOObligationNumber       = record.checkString("HZZOObligationNumber");
                leav.HZZOBussinesEntityCode     = record.checkString("HZZOBussinesEntityCode");

                leav.ChangeDate = record.checkDate("ChangeDate");

                leav.Owner       = record.checkBoolean("Owner");
                leav.LegalEntity = record.checkBoolean("LegalEntity");
                leav.Active      = record.checkBoolean("Active");

                legalEntityAuditViewList.Add(leav);
            }

            // Connect all foreign keys and return data collection as List<LegalEntityAuditView>
            IFormsRepository  formsRepository = new FormsRepository(context);
            IQueryable <Form> formsTable      = formsRepository.GetValid();

            IActivitiesRepository activitiesRepository = new ActivitiesRepository(context);
            IQueryable <Activity> activitiesTable      = activitiesRepository.GetValid();

            IRegionalOfficesRepository  regionalOfficesRepository = new RegionalOfficesRepository(context);
            IQueryable <RegionalOffice> regionalOfficesTable      = regionalOfficesRepository.GetValid();

            ISubstationsRepository  substationsRepository = new SubstationsRepository(context);
            IQueryable <Substation> substationsTable      = substationsRepository.GetValid();

            ICommercialCourtsRepository  commercialCourtsRepository = new CommercialCourtsRepository(context);
            IQueryable <CommercialCourt> commercialCourtsTable      = commercialCourtsRepository.GetValid();

            ITaxesRepository taxesRepository = new TaxesRepository(context);
            IQueryable <Tax> taxesTable      = taxesRepository.GetValid();

            ICountriesRepository countriesRepository = new CountriesRepository(context);
            IQueryable <Country> countriesTable      = countriesRepository.GetValid();

            ICountiesRepository countiesRepository = new CountiesRepository(context);
            IQueryable <County> countiesTable      = countiesRepository.GetValid();

            ICitiesCommunitiesRepository citiesCommunitiesRepository = new CitiesCommunitiesRepository(context);
            IQueryable <CityCommunity>   cityCommunityTable          = citiesCommunitiesRepository.GetValid();

            IPostalOfficesRepository  postalOfficesRepository = new PostalOfficesRepository(context);
            IQueryable <PostalOffice> postalOfficeTable       = postalOfficesRepository.GetValid();

            IPlacesRepository  placesRepository = new PlacesRepository(context);
            IQueryable <Place> placesTable      = placesRepository.GetValid();

            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(context);
            IQueryable <PhysicalEntity> physicalEntitiesTable      = physicalEntitiesRepository.GetValid();

            List <LegalEntityAuditView> legalEntityAuditView =
                (from t in legalEntityAuditViewList
                 from t1 in formsTable.Where(tbl => tbl.FormPK == t.FormFK).DefaultIfEmpty()
                 from t2 in activitiesTable.Where(tbl => tbl.ActivityPK == t.ActivityFK).DefaultIfEmpty()
                 from t3 in regionalOfficesTable.Where(tbl => tbl.RegionalOfficePK == t.RegionalOfficeFK).DefaultIfEmpty()
                 from t4 in substationsTable.Where(tbl => tbl.SubstationPK == t.SubstationFK).DefaultIfEmpty()
                 from t5 in commercialCourtsTable.Where(tbl => tbl.CommercialCourtPK == t.CommercialCourtFK).DefaultIfEmpty()
                 from t6 in taxesTable.Where(tbl => tbl.TaxPK == t.TaxFK).DefaultIfEmpty()
                 from t7 in countriesTable.Where(tbl => tbl.CountryPK == t.CountryFK).DefaultIfEmpty()
                 from t8 in countiesTable.Where(tbl => tbl.CountyPK == t.CountyFK).DefaultIfEmpty()
                 from t9 in cityCommunityTable.Where(tbl => tbl.CityCommunityPK == t.CityCommunityFK).DefaultIfEmpty()
                 from t10 in postalOfficeTable.Where(tbl => tbl.PostalOfficePK == t.PostalOfficeFK).DefaultIfEmpty()
                 from t11 in placesTable.Where(tbl => tbl.PlacePK == t.PlaceFK).DefaultIfEmpty()
                 from t12 in physicalEntitiesTable.Where(tbl => tbl.PhysicalEntityPK == t.ReferentFK).DefaultIfEmpty()

                 select new LegalEntityAuditView
            {
                LegalEntityPK = t.LegalEntityPK,
                Name = t.Name != null ? t.Name : null,
                ShortName = t.ShortName != null ? t.ShortName : null,
                OIB = t.OIB != null ? t.OIB : null,
                MB = t.MB != null ? t.MB : null,
                MBS = t.MBS != null ? t.MBS : null,
                ActivityFK = t.ActivityFK != null ? t.ActivityFK : null,
                ActivityDescription = t.ActivityDescription != null ? t.ActivityDescription : null,
                FormFK = t.FormFK != null ? t.FormFK : null,
                FundamentalCapital = t.FundamentalCapital != null ? t.FundamentalCapital : null,

                CountryFK = t.CountryFK != null ? t.CountryFK : null,
                CountyFK = t.CountyFK != null ? t.CountyFK : null,
                CityCommunityFK = t.CityCommunityFK != null ? t.CityCommunityFK : null,
                PostalOfficeFK = t.PostalOfficeFK != null ? t.PostalOfficeFK : null,
                PlaceFK = t.PlaceFK != null ? t.PlaceFK : null,
                Place = t.Place != null ? t.Place : null,
                StreetName = t.StreetName != null ? t.StreetName : null,

                RegionalOfficeFK = t.RegionalOfficeFK != null ? t.RegionalOfficeFK : null,
                SubstationFK = t.SubstationFK != null ? t.SubstationFK : null,
                ReferentFK = t.ReferentFK != null ? t.ReferentFK : null,
                DateOfRegistration = t.DateOfRegistration != null ? t.DateOfRegistration : null,
                CommercialCourtFK = t.CommercialCourtFK != null ? t.CommercialCourtFK : null,
                TaxFK = t.TaxFK != null ? t.TaxFK : null,

                Phone = t.Phone != null ? t.Phone : null,
                Fax = t.Fax != null ? t.Fax : null,
                Mobile = t.Mobile != null ? t.Mobile : null,
                EMail = t.EMail != null ? t.EMail : null,
                FirstContactDate = t.FirstContactDate != null ? t.FirstContactDate : null,
                TouristOffice = t.TouristOffice != null ? t.TouristOffice : null,
                TouristOfficeDescription = t.TouristOfficeDescription != null ? t.TouristOfficeDescription : null,
                MonumentAnnuity = t.MonumentAnnuity != null ? t.MonumentAnnuity : null,
                MonumentAnnuityDescription = t.MonumentAnnuityDescription != null ? t.MonumentAnnuityDescription : null,
                NumberOfEmployees = t.NumberOfEmployees != null ? t.NumberOfEmployees : null,
                MIORRegistrationNumber = t.MIORRegistrationNumber != null ? t.MIORRegistrationNumber : null,
                HZZOObligationNumber = t.HZZOObligationNumber != null ? t.HZZOObligationNumber : null,
                HZZOBussinesEntityCode = t.HZZOBussinesEntityCode != null ? t.HZZOBussinesEntityCode : null,
                ChangeDate = t.ChangeDate != null ? t.ChangeDate : null,

                Owner = t.Owner != null ? t.Owner : null,
                LegalEntity = t.LegalEntity != null ? t.LegalEntity : null,
                Active = t.Active != null ? t.Active : null,
                Deleted = t.Deleted != null ? t.Deleted : null,

                FormName = t1 != null && t1.Name != null ? t1.Name : null,
                ActivityName = t2 != null && t2.Name != null ? t2.Name : null,
                RegionalOfficeName = t3 != null && t3.Name != null ? t3.Name : null,
                SubstationName = t4 != null && t4.Name != null ? t4.Name : null,
                ReferentName = t12 != null && t12.Firstname != null && t12.Lastname != null ? t12.Firstname + " " + t12.Lastname : null,
                CommercialCourtName = t5 != null && t5.Name != null ? t5.Name : null,
                TaxName = t6 != null && t6.Name != null ? t6.Name : null,
                CountryName = t7 != null && t7.Name != null ? t7.Name : null,
                CountyName = t8 != null && t8.Name != null ? t8.Name : null,
                CityCommunityName = t9 != null && t9.Name != null ? t9.Name : null,
                PostalOfficeName = t10 != null && t10.Name != null ? t10.Name : null,
                PlaceName = t11 != null && t11.Name != null ? t11.Name : null,
            }).OrderBy(c => c.ChangeDate).ToList();

            return(legalEntityAuditView);
        }
예제 #9
0
        public void BindDDLs(CountyView countyView, ObjectContext db)
        {
            ICountriesRepository countriesRepository = new CountriesRepository(db);

            countyView.Countries = new SelectList(countriesRepository.GetValid().OrderBy("Name ASC").ToList(), "CountryPK", "Name");
        }
예제 #10
0
        public ActionResult Edit(AssessmentsView assessmentView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                IAssessmentsRepository assessmentsRepository = new AssessmentsRepository(db);
                Assessment             assessment            = assessmentsRepository.GetAssessmentByPK((int)assessmentView.AssessmentPK);

                IAssessmentAnswersRepository assessmentAnswersRepository = new AssessmentAnswersRepository(db);

                // Delete old values
                assessmentAnswersRepository.Delete(a => a.AssessmentFK == assessment.AssessmentPK);

                // Add new values
                IAssessmentGroupsRepository    assessmentGroupsRepository    = new AssessmentGroupsRepository(db);
                IAssessmentQuestionsRepository assessmentQuestionsRepository = new AssessmentQuestionsRepository(db);
                IAssessmentTypesRepository     assessmentTypesRepository     = new AssessmentTypesRepository(db);

                assessmentView.AssessmentsTypesView = AssessmentsView.FillQuiz(assessmentTypesRepository.GetValid(), assessmentGroupsRepository, assessmentQuestionsRepository, form);

                // Fetching answered type
                AssessmentsTypeView atw = assessmentView.AssessmentsTypesView.Where(a => a.AssessmentType.AssessmentTypePK == assessmentView.AssessmentTypeFK).First();

                List <AssessmentAnswers> assessmentAnswers = AssessmentAnswerView.ExtractQuizAnswers(atw, assessment.AssessmentPK);

                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                LegalEntity legalEntity             = legalEntitiesRepository.GetLegalEntityByPK((int)assessmentView.LegalEntityFK);
                bool        activityHighRisky       = legalEntity.Activity.HighRisk != null && (bool)legalEntity.Activity.HighRisk ? true : false;
                bool        activityLowRisky        = legalEntity.Activity.LowRisk != null && (bool)legalEntity.Activity.LowRisk ? true : false;
                bool        headquarterCountryRisky = legalEntity.Country.Risk != null && (bool)legalEntity.Country.Risk ? true : false;

                IRisksRepository risksRepository = new RisksRepository(db);
                if (activityHighRisky || headquarterCountryRisky) // check explicitly if related legalEntity activity is high risk
                {
                    assessmentView.RiskFK = risksRepository.GetRiskByName("Visok").RiskPK;
                }
                else if (activityLowRisky) // check explicitly if related legalEntity activity is low risk
                {
                    assessmentView.RiskFK = risksRepository.GetRiskByName("Nizak").RiskPK;
                }
                else // run assesment quiz
                {
                    ILegalEntityOwnersRepository  legalEntityOwnersRepository = new LegalEntityOwnersRepository(db);
                    IQueryable <LegalEntityOwner> legalEntityOwnersTable      = legalEntityOwnersRepository.GetValid();
                    ICountriesRepository          countriesRepository         = new CountriesRepository(db);

                    IActivitiesRepository activitiesRepository = new ActivitiesRepository(db);

                    List <LegalEntityOwner> coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity((int)assessmentView.LegalEntityFK).ToList();

                    legalEntityOwnersTable = LegalEntityOwnerView.GetLegalEntityOwnersForLegalEntity(Convert.ToInt32(assessmentView.LegalEntityFK), coList, legalEntityOwnersTable);

                    IQueryable <LegalEntity> legalEntityView = LegalEntityOwnerView.GetRelatedLegalEntities(legalEntityOwnersTable, legalEntitiesRepository.GetValid(), countriesRepository.GetValid(), activitiesRepository.GetValid());

                    // check owners risks
                    bool ownersResidenceCountryRisky = false;
                    bool ownersActivitiesHighlyRisky = false;
                    bool ownersActivitiesLowRisky    = false;

                    if (legalEntityView.Count() > 0)
                    {
                        if (legalEntityView.ToList().TrueForAll(le => le.Country.Risk == null || (le.Country.Risk != null && (bool)le.Country.Risk != true)) == false)
                        {
                            ownersResidenceCountryRisky = true;
                        }

                        if (legalEntityView.ToList().TrueForAll(le => le.Activity == null || (le.Activity.HighRisk == null || (le.Activity.HighRisk != null && (bool)le.Activity.HighRisk != true))) == false)
                        {
                            ownersActivitiesHighlyRisky = true;
                        }

                        if (legalEntityView.ToList().TrueForAll(le => le.Activity == null || (le.Activity.LowRisk == null || (le.Activity.LowRisk != null && (bool)le.Activity.LowRisk != true))) == false)
                        {
                            ownersActivitiesLowRisky = true;
                        }
                    }

                    // check form
                    bool allAnswersYes = false;
                    bool allAnswersNo  = false;
                    bool mixedAnswers  = false;

                    if (assessmentAnswers.TrueForAll(aa => aa.AssessmentAnswer != null && (bool)aa.AssessmentAnswer == true))
                    {
                        allAnswersYes = true;
                    }

                    if (assessmentAnswers.TrueForAll(aa => aa.AssessmentAnswer != null && (bool)aa.AssessmentAnswer == false))
                    {
                        allAnswersNo = true;
                    }

                    if (allAnswersYes == false && allAnswersNo == false)
                    {
                        mixedAnswers = true;
                    }

                    // check general conditions
                    if (ownersActivitiesLowRisky)
                    {
                        assessmentView.RiskFK = risksRepository.GetRiskByName("Nizak").RiskPK;
                    }
                    else if (allAnswersYes || ownersResidenceCountryRisky || ownersActivitiesHighlyRisky)
                    {
                        assessmentView.RiskFK = risksRepository.GetRiskByName("Visok").RiskPK;
                    }
                    else if (allAnswersNo || mixedAnswers)
                    {
                        assessmentView.RiskFK = risksRepository.GetRiskByName("Srednji").RiskPK;
                    }
                }

                if (assessmentAnswers.Count() > 0)
                {
                    assessmentAnswersRepository.AddAll(assessmentAnswers);
                    assessmentAnswersRepository.SaveChanges();
                }

                assessmentView.ConvertTo(assessmentView, assessment);
                assessmentsRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", assessment.AssessmentPK);

                return(RedirectToAction("Index", "Assessment"));
            }
            else
            {
                IAssessmentGroupsRepository    assessmentGroupsRepository    = new AssessmentGroupsRepository(db);
                IAssessmentQuestionsRepository assessmentQuestionsRepository = new AssessmentQuestionsRepository(db);

                //Assessment types ddl
                IAssessmentTypesRepository assessmentTypesRepository = new AssessmentTypesRepository(db);
                assessmentView.AssessmentTypes = new SelectList(assessmentTypesRepository.GetValid().OrderBy("Name ASC").ToList(), "AssessmentTypePK", "Name");

                //legalEntities ddl
                ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);
                assessmentView.LegalEntities = new SelectList(legalEntitiesRepository.GetValidLegalEntities().ToList(), "LegalEntityPK", "Name");

                assessmentView.AssessmentsTypesView = AssessmentsView.FillQuiz(assessmentTypesRepository.GetValid(), assessmentGroupsRepository, assessmentQuestionsRepository, form);

                return(View(assessmentView));
            }
        }