public ActionResult GetSubstationsByRegionalOffice(int regionalOffice) { ISubstationsRepository substationsRepository = new SubstationsRepository(db); var substations = substationsRepository.GetValidByRegionalOffice(regionalOffice).OrderBy(x => x.Name); return(Json(substations.Select(c => new { value = c.SubstationPK, text = c.Name }), JsonRequestBehavior.AllowGet)); }
public ActionResult Index() { ISubstationsRepository substationsRepository = new SubstationsRepository(db); IRegionalOfficesRepository regionalOfficesRepository = new RegionalOfficesRepository(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"] : "SubstationPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IQueryable <SubstationView> substations = SubstationView.GetSubstationView(substationsRepository.GetValid(), regionalOfficesRepository.GetValid()) .OrderBy(ordering); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); substations = substations.Where(c => c.Name.Contains(searchString)); } substations = substations.Page(page, pageSize); if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"])) { string searchString = Request.QueryString["searchString"].ToString(); ViewData["numberOfRecords"] = substationsRepository.GetValid().Where(c => c.Name.Contains(searchString)).Count(); } else { ViewData["numberOfRecords"] = substationsRepository.GetValid().Count(); } int numberOfPages = ((int)ViewData["numberOfRecords"] + pageSize - 1) / pageSize; if (page > numberOfPages) { string url = LinkHelper.getQueryStringArray(new string[] { "page" }); return(Redirect("Substation?" + url + "page=" + numberOfPages)); } else { return(View("Index", substations.ToList())); } }
public ActionResult Delete(int?substationPK) { ISubstationsRepository substationsRepository = new SubstationsRepository(db); if (substationPK != null) { Substation substation = substationsRepository.GetSubstationByPK((int)substationPK); substation.Deleted = true; substationsRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("DELETE", substation.SubstationPK); } return(Redirect(Request.UrlReferrer.AbsoluteUri)); }
public ActionResult Edit(int?substationPK) { if (substationPK != null) { ISubstationsRepository substationsRepository = new SubstationsRepository(db); Substation substation = substationsRepository.GetSubstationByPK((int)substationPK); SubstationView substationView = new SubstationView(); substationView.ConvertFrom(substation, substationView); substationView.BindDDLs(substationView, db); return(View(substationView)); } else { return(RedirectToAction("Index", "Substation")); } }
public ActionResult Edit(SubstationView substationView) { if (ModelState.IsValid) { ISubstationsRepository substationsRepository = new SubstationsRepository(db); Substation substation = substationsRepository.GetSubstationByPK((int)substationView.SubstationPK); substationView.ConvertTo(substationView, substation); substationsRepository.SaveChanges(); TempData["message"] = LayoutHelper.GetMessage("UPDATE", substation.SubstationPK); return(RedirectToAction("Index", "Substation")); } else { substationView.BindDDLs(substationView, db); return(View(substationView)); } }
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); }
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"); }
public ActionResult LegalEntities(string Name, string OIB, string MB, string MBS, int?BankPK, int?TaxPK, int?FormPK, int?ActivityPK, int?SubstationPK, int?CommercialCourtPK, int?NumberOfEmployeesFrom, int?NumberOfEmployeesTo, int?FundamentalCapitalFrom, int?FundamentalCapitalTo, string TouristOffice, string MonumentAnnuity) { string sortOrder = !string.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC"; string sortColumn = !string.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "LegalEntityPK"; string ordering = sortColumn + " " + sortOrder; ordering = ordering.Trim(); IBanksRepository banksRepository = new BanksRepository(db); ITaxesRepository taxesRepository = new TaxesRepository(db); IFormsRepository formsRepository = new FormsRepository(db); IActivitiesRepository activitiesRepository = new ActivitiesRepository(db); ISubstationsRepository substationsRepository = new SubstationsRepository(db); ICommercialCourtsRepository commercialCourtsRepository = new CommercialCourtsRepository(db); // Binding DDL for report search ViewBag.Banks = new SelectList(banksRepository.GetValid().OrderBy("Name ASC").ToList(), "BankPK", "Name", BankPK); ViewBag.Taxes = new SelectList(taxesRepository.GetValid().OrderBy("Name ASC").ToList(), "TaxPK", "Name", TaxPK); ViewBag.Forms = new SelectList(formsRepository.GetValid().OrderBy("Name ASC").ToList(), "FormPK", "Name", FormPK); ViewBag.Activities = new SelectList(activitiesRepository.GetValid().OrderBy("Name ASC").ToList(), "ActivityPK", "Name", ActivityPK); ViewBag.Substations = new SelectList(substationsRepository.GetValid().OrderBy("Name ASC").ToList(), "SubstationPK", "Name", SubstationPK); ViewBag.CommercialCourts = new SelectList(commercialCourtsRepository.GetValid().OrderBy("Name ASC").ToList(), "CommercialCourtPK", "Name", CommercialCourtPK); if (BankPK != null) { ViewBag.Bank = banksRepository.GetBankByPK((int)BankPK).Name; } if (TaxPK != null) { ViewBag.Tax = taxesRepository.GetTaxByPK((int)TaxPK).Name; } if (SubstationPK != null) { ViewBag.Substation = substationsRepository.GetSubstationByPK((int)SubstationPK).Name; } if (CommercialCourtPK != null) { ViewBag.CommercialCourt = commercialCourtsRepository.GetCommercialCourtByPK((int)CommercialCourtPK).Name; } if (FormPK != null) { ViewBag.Form = formsRepository.GetFormByPK((int)FormPK).Name; } if (ActivityPK != null) { ViewBag.Activity = activitiesRepository.GetActivityByPK((int)ActivityPK).Name; } bool?TouristOfficeFlag = null; bool?MonumentAnnuityFlag = null; if (TouristOffice == "on") { TouristOfficeFlag = true; } if (MonumentAnnuity == "on") { MonumentAnnuityFlag = true; } // Applying filters IQueryable <LegalEntityView> legalEntities = LegalEntityView.GetLegalEntitiesReport(db, Name, OIB, MB, MBS, BankPK, TaxPK, FormPK, ActivityPK, SubstationPK, CommercialCourtPK, NumberOfEmployeesFrom, NumberOfEmployeesTo, FundamentalCapitalFrom, FundamentalCapitalTo, TouristOfficeFlag, MonumentAnnuityFlag) .OrderBy(ordering); // Excluding temporary deleted items from view legalEntitiesPKsToExclude = new List <int>(); // Empty session on first request if (Request.QueryString.Count == 0) { Session["legalEntitiesPKsToExclude"] = null; } if (Session["legalEntitiesPKsToExclude"] != null) { legalEntitiesPKsToExclude = (List <int>)Session["legalEntitiesPKsToExclude"]; legalEntities = legalEntities.Where(c => !legalEntitiesPKsToExclude.Contains(c.LegalEntityPK)); } return(View("LegalEntities", legalEntities.ToList())); }
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); }