Exemple #1
0
        public void BindDLLs(LegalEntityOwnerView legalEntityOwnerView, ObjectContext db)
        {
            //Owners ddl
            IPhysicalEntitiesRepository physicalEntitesRepository = new PhysicalEntitiesRepository(db);
            ILegalEntitiesRepository    legalEntitiesRepository   = new LegalEntitiesRepository(db);

            List <DDLHelper> owners = LegalEntityOwnerView.GetOwnersSelect(physicalEntitesRepository.GetValid(), legalEntitiesRepository.GetValidOwners()).OrderBy("Text ASC").ToList();

            legalEntityOwnerView.Owners = new SelectList(owners, "Value", "Text");

            //AdditionalFactors ddl
            IAdditionalFactorsRepository additionalFactorsRepository = new AdditionalFactorsRepository(db);

            legalEntityOwnerView.AdditionalFactors = new SelectList(additionalFactorsRepository.GetValid().OrderBy("Name ASC").ToList(), "AdditionalFactorPK", "Name");

            //FulfilledFactors ddl
            IFulfilledFactorsRepository fulfilledFactorsRepository = new FulfilledFactorsRepository(db);

            legalEntityOwnerView.FulfilledFactors = new SelectList(fulfilledFactorsRepository.GetValid().OrderBy("Name ASC").ToList(), "FulfilledFactorPK", "Name");

            //BussinesShareBurdens ddl
            IBussinesShareBurdensRepository bussinesShareBurdensRepository = new BussinesShareBurdensRepository(db);

            legalEntityOwnerView.BussinesShareBurdens = new SelectList(bussinesShareBurdensRepository.GetValid().OrderBy("Name ASC").ToList(), "BussinesShareBurdenPK", "Name");

            //ChangeTypes ddl
            IChangeTypesRepository changeTypesRepository = new ChangeTypesRepository(db);

            legalEntityOwnerView.ChangeTypes = new SelectList(changeTypesRepository.GetValid().OrderBy("Name ASC").ToList(), "ChangeTypePK", "Name");
        }
Exemple #2
0
        public ActionResult GetReferentsBySubstation(int substation)
        {
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);
            var physicalEntities = physicalEntitiesRepository.GetValidReferentsBySubstation(substation).OrderBy(c => c.Firstname);

            return(Json(physicalEntities.Select(c => new { value = c.PhysicalEntityPK, text = c.Firstname + " " + c.Lastname }), JsonRequestBehavior.AllowGet));
        }
Exemple #3
0
        public FileContentResult ShowLegalEntityOwnersGraph(int?legalEntityFK, string color, int?dpi)
        {
            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);

            ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db);
            IPhysicalEntitiesRepository  physicalEntitiesRepository  = new PhysicalEntitiesRepository(db);

            List <LegalEntityOwner>       filteredCoList         = new List <LegalEntityOwner>();
            IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid();

            if (legalEntityFK != null)
            {
                List <LegalEntityOwner> coList = new List <LegalEntityOwner>();
                coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity((int)legalEntityFK).ToList();

                foreach (var co in coList)
                {
                    LegalEntityOwnerView.Fill(filteredCoList, legalEntityOwnersTable.ToList(), co);
                }

                legalEntityOwnersTable = filteredCoList.AsQueryable();
            }

            IQueryable <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersTable,
                                                                                                               physicalEntitiesRepository.GetValid(),
                                                                                                               legalEntitiesRepository.GetValid());

            List <string> graphElements = new List <string>();

            foreach (LegalEntityOwnerView item in legalEntityOwners)
            {
                graphElements.Add(item.OwnerFK.ToString() + "[label=\"" + item.OwnerName + "\", shape=ci, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]");

                if (legalEntityFK == item.LegalEntityFK)
                {
                    graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fontcolor=\"white\", color=\"black\", width=1.5]");
                }
                else
                {
                    graphElements.Add(item.LegalEntityFK.ToString() + "[label=\"" + item.LegalEntityName + "\", shape=box, fontsize=12, fontname=arial, labelloc=t, style=filled, fillcolor=\"white\", width=1.5]");
                }

                graphElements.Add(item.OwnerFK.ToString() + "->" + item.LegalEntityFK.ToString());
            }

            string graph = @"digraph Graphviz {";

            graph += "[bgcolor=\"" + color + "\", dpi=\"" + dpi + "\"],";
            graph += string.Join(", ", graphElements.ToArray());
            graph += "}";

            graph = graph.ConvertNonASCIICharacters();

            byte[] imageByte   = imageByte = Graphviz.RenderImage(graph, "dot", "png");;
            string contentType = "image/png";

            return(File(imageByte, contentType));
        }
Exemple #4
0
        public static List <LegalEntityLegalRepresentativeAuditView> GetLegalEntityLegalRepresentativeAuditView(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 == "LegalEntityLegalRepresentatives")
                                 where am.RelatedEntityPK == relatedEntityPK
                                 select new {
                AuditingMasterPK = am.AuditingMasterPK,
                RelatedEntityPK = am.RelatedEntityPK,
                SessionToken = am.SessionToken
            }).ToList();

            List <LegalEntityLegalRepresentativeAuditView> legalEntityLegalRepresentativeAuditViewList = new List <LegalEntityLegalRepresentativeAuditView>();

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

                LegalEntityLegalRepresentativeAuditView legalEntityLegalRepresentativeAuditView = new LegalEntityLegalRepresentativeAuditView();

                legalEntityLegalRepresentativeAuditView.LegalEntityFK         = record.checkInteger("LegalEntityFK");
                legalEntityLegalRepresentativeAuditView.LegalRepresentativeFK = record.checkInteger("LegalRepresentativeFK");
                legalEntityLegalRepresentativeAuditView.WayOfRepresentationFK = record.checkInteger("WayOfRepresentationFK");

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

                legalEntityLegalRepresentativeAuditViewList.Add(legalEntityLegalRepresentativeAuditView);
            }

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

            IWaysOfRepresentationRepository  WaysOfRepresentationRepository = new WaysOfRepresentationRepository(context);
            IQueryable <WayOfRepresentation> wayOfRepresentationTable       = WaysOfRepresentationRepository.GetValid();

            List <LegalEntityLegalRepresentativeAuditView> legalEntityLegalRepresentative =
                (from t in legalEntityLegalRepresentativeAuditViewList
                 from t1 in physicalEntityTable.Where(tbl => tbl.PhysicalEntityPK == t.LegalRepresentativeFK).DefaultIfEmpty()
                 from t2 in wayOfRepresentationTable.Where(tbl => tbl.WayOfRepresentationPK == t.WayOfRepresentationFK).DefaultIfEmpty()
                 where t.ChangeDate != null
                 select new LegalEntityLegalRepresentativeAuditView
            {
                LegalEntityLegalRepresentativePK = t.LegalEntityLegalRepresentativePK,

                LegalRepresentativeName = t1 != null && t1.Firstname != null && t1.Lastname != null  ? t1.Firstname + " " + t1.Lastname : null,
                WayOfRepresentationName = t2 != null && t2.Name != null ? t2.Name : null,

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

            return(legalEntityLegalRepresentative);
        }
Exemple #5
0
        public void BindDDLs(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, ObjectContext db)
        {
            //way of representation ddl
            IWaysOfRepresentationRepository wayOfRepresentationView = new WaysOfRepresentationRepository(db);

            legalEntityLegalRepresentativeView.WaysOfRepresentation = new SelectList(wayOfRepresentationView.GetValid().OrderBy("Name ASC").ToList(), "WayOfRepresentationPK", "Name");

            //physicalEntity ddl
            PhysicalEntityView          PhysicalEntityView         = new PhysicalEntityView();
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);

            legalEntityLegalRepresentativeView.LegalRepresentatives = new SelectList(PhysicalEntityView.GetPhysicalEntitySelect(physicalEntitiesRepository.GetValid()).ToList(), "PhysicalEntityPK", "Name");
        }
Exemple #6
0
        public ActionResult UnLegalRepresentative(int?physicalEntityPK)
        {
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);

            if (physicalEntityPK != null)
            {
                PhysicalEntity physicalEntity = physicalEntitiesRepository.GetPhysicalEntityByPK((int)physicalEntityPK);

                physicalEntity.LegalRepresentative = false;

                physicalEntitiesRepository.SaveChanges();
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Exemple #7
0
        public ActionResult Owner(int?physicalEntityPK)
        {
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);

            if (physicalEntityPK != null)
            {
                PhysicalEntity physicalEntity = physicalEntitiesRepository.GetPhysicalEntityByPK((int)physicalEntityPK);

                physicalEntity.Owner = true;

                physicalEntitiesRepository.SaveChanges();
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Exemple #8
0
        public ActionResult Delete(int?physicalEntityPK)
        {
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);

            if (physicalEntityPK != null)
            {
                PhysicalEntity physicalEntity = physicalEntitiesRepository.GetPhysicalEntityByPK((int)physicalEntityPK);

                physicalEntity.Deleted = true;

                physicalEntitiesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", physicalEntity.PhysicalEntityPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Exemple #9
0
        public ActionResult Index()
        {
            ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);
            LegalEntityLegalRepresentativeView         legalEntityLegalRepresentativeView        = new LegalEntityLegalRepresentativeView();
            IContractsRepository           contractsRepository           = new ContractsRepository(db);
            ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
            ILegalEntitiesRepository       legalEntitiesRepository       = new LegalEntitiesRepository(db);
            IPhysicalEntitiesRepository    physicalEntitiesRepository    = new PhysicalEntitiesRepository(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"] : "LegalEntityLegalRepresentativePK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <LegalEntityLegalRepresentativeView> legalEntityLegalRepresentatives = LegalEntityLegalRepresentativeView.GetLegalEntityLegalRepresentativeView(legalEntityLegalRepresentativesRepository.GetValid(), legalEntitiesRepository.GetValid(), physicalEntitiesRepository.GetValid())
                                                                                              .OrderBy(ordering);

            //legalEntities ddl
            ViewBag.LegalEntities = new SelectList(legalEntitiesRepository.GetValidLegalEntities().OrderBy("Name ASC").ToList(), "LegalEntityPK", "Name", Request.QueryString["legalEntityFK"]);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["legalEntityFK"]))
            {
                int legalEntityFK = Convert.ToInt32(Request.QueryString["legalEntityFK"]);
                legalEntityLegalRepresentatives = legalEntityLegalRepresentatives.Where(c => c.LegalEntityFK == legalEntityFK);
            }

            legalEntityLegalRepresentatives = legalEntityLegalRepresentatives.Page(page, pageSize);

            ViewData["numberOfRecords"] = legalEntityLegalRepresentatives.Count();

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

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("LegalEntityLegalRepresentative?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", legalEntityLegalRepresentatives.ToList()));
            }
        }
Exemple #10
0
        public ActionResult Edit(int?physicalEntityPK)
        {
            if (physicalEntityPK != null)
            {
                IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);
                PhysicalEntity     physicalEntity     = physicalEntitiesRepository.GetPhysicalEntityByPK((int)physicalEntityPK);
                PhysicalEntityView physicalEntityView = new PhysicalEntityView();

                physicalEntityView.ConvertFrom(physicalEntity, physicalEntityView);
                physicalEntityView.BindDDLs(physicalEntityView, db);

                return(View(physicalEntityView));
            }
            else
            {
                return(RedirectToAction("Index", "PhysicalEntity"));
            }
        }
Exemple #11
0
        public static List <List <LegalEntityOwnerAuditView> > GetLegalEntityOwnersAuditView(ObjectContext context, int legalEntityFK)
        {
            ILegalEntitiesRepository     legalEntitiesRepository     = new LegalEntitiesRepository(context);
            IPhysicalEntitiesRepository  physicalEntitiesRepository  = new PhysicalEntitiesRepository(context);
            ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(context);

            // get all legalEntity branches
            List <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersRepository.GetAll(), physicalEntitiesRepository.GetValid(), legalEntitiesRepository.GetValid())
                                                            .Where(c => c.LegalEntityFK == legalEntityFK)
                                                            .ToList();

            List <List <LegalEntityOwnerAuditView> > legalEntityOwnersListList = new List <List <LegalEntityOwnerAuditView> >();

            foreach (LegalEntityOwnerView legalEntityOwner in legalEntityOwners)
            {
                legalEntityOwnersListList.Add(LegalEntityOwnerAuditView.GetLegalEntityOwnerAuditView(context, legalEntityOwner.LegalEntityOwnerPK));
            }

            return(legalEntityOwnersListList);
        }
Exemple #12
0
        public ActionResult Edit(PhysicalEntityView physicalEntityView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);
                PhysicalEntity physicalEntity = physicalEntitiesRepository.GetPhysicalEntityByPK((int)physicalEntityView.PhysicalEntityPK);
                physicalEntityView.ConvertTo(physicalEntityView, physicalEntity);

                physicalEntitiesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", physicalEntity.PhysicalEntityPK);

                return(RedirectToAction("Index", "PhysicalEntity"));
            }
            else
            {
                physicalEntityView.BindDDLs(physicalEntityView, db);

                return(View(physicalEntityView));
            }
        }
Exemple #13
0
        public ActionResult Index()
        {
            ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db);
            ILegalEntitiesRepository     legalEntitiesRepository     = new LegalEntitiesRepository(db);
            IPhysicalEntitiesRepository  physicalEntitiesRepository  = new PhysicalEntitiesRepository(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"] : "LegalEntityOwnerPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            List <LegalEntityOwner>       filteredCoList         = new List <LegalEntityOwner>();
            IQueryable <LegalEntityOwner> legalEntityOwnersTable = legalEntityOwnersRepository.GetValid();

            //if (!String.IsNullOrWhiteSpace(Request.QueryString["legalEntityFK"]))
            //{
            //    List<LegalEntityOwner> coList = new List<LegalEntityOwner>();
            //    coList = legalEntityOwnersRepository.GetFirstLegalEntityOwnersForLegalEntity(Convert.ToInt32(Request.QueryString["legalEntityFK"])).ToList();

            //    foreach (var co in coList)
            //    {
            //        LegalEntityOwnerView.Fill(filteredCoList, legalEntityOwnersTable.ToList(), co);
            //    }

            //    legalEntityOwnersTable = filteredCoList.AsQueryable();
            //}

            IQueryable <LegalEntityOwnerView> legalEntityOwners = LegalEntityOwnerView.GetLegalEntityOwnerView(legalEntityOwnersTable,
                                                                                                               physicalEntitiesRepository.GetValid(),
                                                                                                               legalEntitiesRepository.GetValid())
                                                                  .OrderBy(ordering);

            //LegalEntities ddl
            ViewBag.LegalEntities = new SelectList(legalEntitiesRepository.GetValid().OrderBy("Name ASC").ToList(), "LegalEntityPK", "Name", Request.QueryString["legalEntityFK"]);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["legalEntityFK"]))
            {
                int legalEntityFK = Convert.ToInt32(Request.QueryString["legalEntityFK"]);
                legalEntityOwners = legalEntityOwners.Where(c => c.LegalEntityFK == legalEntityFK);
            }

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                legalEntityOwners = legalEntityOwners.Where(c => c.OwnerName.Contains(searchString));
            }

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                ViewData["numberOfRecords"] = legalEntityOwners.Where(c => c.OwnerName.Contains(searchString)).Count();
            }
            else
            {
                ViewData["numberOfRecords"] = legalEntityOwners.Count();
            }

            legalEntityOwners = legalEntityOwners.Page(page, pageSize);

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

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("LegalEntityOwner?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", legalEntityOwners.ToList()));
            }
        }
Exemple #14
0
        public static List <LegalEntityOwnerAuditView> GetLegalEntityOwnerAuditView(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 == "LegalEntityOwners")
                                 where am.RelatedEntityPK == relatedEntityPK
                                 select new {
                AuditingMasterPK = am.AuditingMasterPK,
                RelatedEntityPK = am.RelatedEntityPK,
                SessionToken = am.SessionToken
            }).ToList();

            List <LegalEntityOwnerAuditView> legalEntityOwnerAuditViewList = new List <LegalEntityOwnerAuditView>();

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

                LegalEntityOwnerAuditView legalEntityOwnerAuditView = new LegalEntityOwnerAuditView();

                legalEntityOwnerAuditView.LegalEntityFK = record.checkInteger("LegalEntityFK");
                legalEntityOwnerAuditView.OwnerFK       = record.checkInteger("OwnerFK");
                legalEntityOwnerAuditView.OwnerType     = record.checkString("OwnerType");

                legalEntityOwnerAuditView.BusinessShareAmount        = record.checkDecimal("BusinessShareAmount");
                legalEntityOwnerAuditView.PaidBussinesShareAmount    = record.checkDecimal("PaidBussinesShareAmount");
                legalEntityOwnerAuditView.NominalBussinesShareAmount = record.checkDecimal("NominalBussinesShareAmount");

                legalEntityOwnerAuditView.AdditionalFactorFK    = record.checkInteger("AdditionalFactorFK");
                legalEntityOwnerAuditView.FulfilledFactorFK     = record.checkInteger("FulfilledFactorFK");
                legalEntityOwnerAuditView.BussinesShareBurdenFK = record.checkInteger("BussinesShareBurdenFK");
                legalEntityOwnerAuditView.ChangeTypeFK          = record.checkInteger("ChangeTypeFK");
                legalEntityOwnerAuditView.NumberOfVotes         = record.checkInteger("NumberOfVotes");

                legalEntityOwnerAuditView.EntryDate  = record.checkDate("EntryDate");
                legalEntityOwnerAuditView.ChangeDate = record.checkDate("ChangeDate");

                legalEntityOwnerAuditView.Deleted = record.checkBoolean("Deleted");

                legalEntityOwnerAuditViewList.Add(legalEntityOwnerAuditView);
            }

            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(context);
            IQueryable <LegalEntity> legalEntitiesTable      = legalEntitiesRepository.GetValid();

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

            IAdditionalFactorsRepository  additionalFactorsRepository = new AdditionalFactorsRepository(context);
            IQueryable <AdditionalFactor> additionalFactorsTable      = additionalFactorsRepository.GetValid();

            IFulfilledFactorsRepository  fulfilledFactorsRepository = new FulfilledFactorsRepository(context);
            IQueryable <FulfilledFactor> fulfilledFactorsTable      = fulfilledFactorsRepository.GetValid();

            IBussinesShareBurdensRepository  bussinesShareBurdensRepository = new BussinesShareBurdensRepository(context);
            IQueryable <BussinesShareBurden> bussinesShareBurdensTable      = bussinesShareBurdensRepository.GetValid();

            IChangeTypesRepository  changeTypesRepository = new ChangeTypesRepository(context);
            IQueryable <ChangeType> changeTypesTable      = changeTypesRepository.GetValid();

            IQueryable <LegalEntityOwnerAuditView> legalEntityOwnersLE =
                (from t in legalEntityOwnerAuditViewList
                 from t1 in legalEntitiesTable.Where(tbl => tbl.LegalEntityPK == t.OwnerFK).DefaultIfEmpty()
                 from t2 in additionalFactorsTable.Where(tbl => tbl.AdditionalFactorPK == t.AdditionalFactorFK).DefaultIfEmpty()
                 from t3 in fulfilledFactorsTable.Where(tbl => tbl.FulfilledFactorPK == t.FulfilledFactorFK).DefaultIfEmpty()
                 from t4 in bussinesShareBurdensTable.Where(tbl => tbl.BussinesShareBurdenPK == t.BussinesShareBurdenFK).DefaultIfEmpty()
                 from t5 in changeTypesTable.Where(tbl => tbl.ChangeTypePK == t.ChangeTypeFK).DefaultIfEmpty()

                 where t.ChangeDate != null && t.OwnerType != null && t.OwnerType.Contains("le")
                 select new LegalEntityOwnerAuditView
            {
                LegalEntityOwnerPK = t.LegalEntityOwnerPK,

                OwnerName = t1 != null && t1.Name != null ? t1.Name : null,
                AdditionalFactorName = t2 != null && t2.Name != null ? t2.Name : null,
                FulfilledFactorName = t3 != null && t3.Name != null ? t3.Name : null,
                BussinesShareBurdenName = t4 != null && t4.Name != null ? t4.Name : null,
                ChangeTypeName = t5 != null && t5.Name != null ? t5.Name : null,

                BusinessShareAmount = t.BusinessShareAmount != null ? t.BusinessShareAmount : null,
                PaidBussinesShareAmount = t.PaidBussinesShareAmount != null ? t.PaidBussinesShareAmount : null,
                NominalBussinesShareAmount = t.NominalBussinesShareAmount != null ? t.NominalBussinesShareAmount : null,

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

                EntryDate = t.EntryDate != null ? t.EntryDate : null,
                ChangeDate = t.ChangeDate != null ? t.ChangeDate : null,
                Deleted = t.Deleted != null ? t.Deleted : null,
            }).AsQueryable <LegalEntityOwnerAuditView>();


            IQueryable <LegalEntityOwnerAuditView> legalEntityOwnersPE =
                (from t in legalEntityOwnerAuditViewList
                 from t1 in physicalEntitiesTable.Where(tbl => tbl.PhysicalEntityPK == t.OwnerFK).DefaultIfEmpty()
                 from t2 in additionalFactorsTable.Where(tbl => tbl.AdditionalFactorPK == t.AdditionalFactorFK).DefaultIfEmpty()
                 from t3 in fulfilledFactorsTable.Where(tbl => tbl.FulfilledFactorPK == t.FulfilledFactorFK).DefaultIfEmpty()
                 from t4 in bussinesShareBurdensTable.Where(tbl => tbl.BussinesShareBurdenPK == t.BussinesShareBurdenFK).DefaultIfEmpty()
                 from t5 in changeTypesTable.Where(tbl => tbl.ChangeTypePK == t.ChangeTypeFK).DefaultIfEmpty()

                 where t.ChangeDate != null && t.OwnerType != null && t.OwnerType.Contains("pe")
                 select new LegalEntityOwnerAuditView
            {
                LegalEntityOwnerPK = t.LegalEntityOwnerPK,

                OwnerName = t1 != null && t1.Firstname != null && t1.Lastname != null ? t1.Firstname + " " + t1.Lastname : null,
                AdditionalFactorName = t2 != null && t2.Name != null ? t2.Name : null,
                FulfilledFactorName = t3 != null && t3.Name != null ? t3.Name : null,
                BussinesShareBurdenName = t4 != null && t4.Name != null ? t4.Name : null,
                ChangeTypeName = t5 != null && t5.Name != null ? t5.Name : null,

                BusinessShareAmount = t.BusinessShareAmount != null ? t.BusinessShareAmount : null,
                PaidBussinesShareAmount = t.PaidBussinesShareAmount != null ? t.PaidBussinesShareAmount : null,
                NominalBussinesShareAmount = t.NominalBussinesShareAmount != null ? t.NominalBussinesShareAmount : null,

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

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

                ChangeDate = t.ChangeDate != null ? t.ChangeDate : null,
                Deleted = t.Deleted != null ? t.Deleted : null,
            }).AsQueryable <LegalEntityOwnerAuditView>();


            List <LegalEntityOwnerAuditView> legalEntityOwners = legalEntityOwnersLE.Union(legalEntityOwnersPE).OrderBy(c => c.ChangeDate).ToList();

            return(legalEntityOwners);
        }
Exemple #15
0
        //[PITAuthorize(Roles = "add, edit, view, delete")]
        public ActionResult LegalEntity(int?legalEntityFK, string ShowBasicInfo, string ShowLegalEntityHistory, string ShowLegalEntityLegalRepresentatives, string ShowLegalEntityLegalRepresentativesHistory, string ShowLegalEntityBanks, string ShowLegalEntityBanksHistory, string ShowContracts, string ShowBranches, string ShowBranchesHistory, string ShowLegalEntityOwners, string ShowLegalEntityOwnersHistory)
        {
            LegalEntityView legalEntityView = new LegalEntityView();

            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);

            if (legalEntityFK != null)
            {
                int legalEntityPK = (int)legalEntityFK;

                if (ShowBasicInfo == "on" || ShowBasicInfo == "true")
                {
                    legalEntityView = LegalEntityView.GetLegalEntityReport(db, legalEntityPK);
                }

                if (ShowLegalEntityLegalRepresentatives == "on" || ShowLegalEntityLegalRepresentatives == "true")
                {
                    IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(db);
                    ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);

                    IQueryable <LegalEntityLegalRepresentativeView> legalEntityLegalRepresentatives = LegalEntityLegalRepresentativeView.GetLegalEntityLegalRepresentativeView(legalEntityLegalRepresentativesRepository.GetValid(), legalEntitiesRepository.GetValidLegalEntities(), physicalEntitiesRepository.GetValid());

                    ViewBag.LegalEntityLegalRepresentatives = legalEntityLegalRepresentatives.Where(c => c.LegalEntityFK == legalEntityPK).ToList();
                }

                if (ShowLegalEntityBanks == "on" || ShowLegalEntityBanks == "true")
                {
                    ILegalEntityBanksRepository legalEntitiesBanksRepository = new LegalEntityBanksRepository(db);
                    IBanksRepository            banksRepository = new BanksRepository(db);

                    IQueryable <LegalEntityBankView> legalEntitiesBanks = LegalEntityBankView.GetLegalEntityBankView(legalEntitiesBanksRepository.GetValid(), banksRepository.GetValid(), legalEntitiesRepository.GetValidLegalEntities());

                    ViewBag.LegalEntityBanks = legalEntitiesBanks.Where(c => c.LegalEntityFK == legalEntityPK).ToList();
                }

                if (ShowContracts == "on" || ShowContracts == "true")
                {
                    IContractsRepository      contractsRepository      = new ContractsRepository(db);
                    IAnnexContractsRepository annexContractsRepository = new AnnexContractsRepository(db);

                    IQueryable <ContractView> contracts = ContractView.GetContractsView(contractsRepository.GetValid(), annexContractsRepository.GetValid(), legalEntitiesRepository.GetValidLegalEntities());

                    ViewBag.Contracts = contracts.Where(c => c.LegalEntityFK == legalEntityPK).ToList();
                }

                if (ShowBranches == "on" || ShowBranches == "true")
                {
                    ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);

                    IQueryable <LegalEntityBranchView> legalEntityBranches = LegalEntityBranchView.GetLegalEntityBranchView(legalEntityBranchesRepository.GetValid(), legalEntitiesRepository.GetValidLegalEntities());

                    ViewBag.Branches = legalEntityBranches.Where(c => c.LegalEntityFK == legalEntityPK).ToList();
                }

                // history
                if (ShowLegalEntityHistory == "on" || ShowLegalEntityHistory == "true")
                {
                    List <LegalEntityAuditView> legalEntityHistory = LegalEntityAuditView.GetLegalEntityAuditView(db, legalEntityPK);
                    ViewBag.legalEntityHistory = legalEntityHistory.ToList();
                }

                if (ShowLegalEntityBanksHistory == "on" || ShowLegalEntityBanksHistory == "true")
                {
                    List <List <LegalEntityBankAuditView> > legalEntityBanksHistory = LegalEntityBankAuditView.GetLegalEntityBanksAuditView(db, legalEntityPK);

                    List <DateTime> legalEntityBanksDatesHistory = new List <DateTime>();

                    foreach (List <LegalEntityBankAuditView> legalEntityBank in legalEntityBanksHistory)
                    {
                        foreach (LegalEntityBankAuditView legalEntityBankAuditView in legalEntityBank)
                        {
                            if (!legalEntityBanksDatesHistory.Contains(legalEntityBankAuditView.ChangeDate.Value))
                            {
                                legalEntityBanksDatesHistory.Add(legalEntityBankAuditView.ChangeDate.Value);
                            }
                        }
                    }

                    ViewBag.legalEntityBanksDatesHistory = legalEntityBanksDatesHistory.OrderBy(c => c.Date).ToList();
                    ViewBag.legalEntityBanksHistory      = legalEntityBanksHistory;
                }

                if (ShowLegalEntityLegalRepresentativesHistory == "on" || ShowLegalEntityLegalRepresentativesHistory == "true")
                {
                    List <List <LegalEntityLegalRepresentativeAuditView> > legalEntityLegalRepresentativesHistory = LegalEntityLegalRepresentativeAuditView.GetLegalEntityLegalRepresentativesAuditView(db, legalEntityPK);
                    ViewBag.legalEntityLegalRepresentativesHistory = legalEntityLegalRepresentativesHistory;
                }

                if (ShowLegalEntityOwnersHistory == "on" || ShowLegalEntityOwnersHistory == "true")
                {
                    List <List <LegalEntityOwnerAuditView> > legalEntityOwnersHistory = LegalEntityOwnerAuditView.GetLegalEntityOwnersAuditView(db, legalEntityPK);
                    ViewBag.legalEntityOwnersHistory = legalEntityOwnersHistory;
                }

                if (ShowBranchesHistory == "on" || ShowBranchesHistory == "on")
                {
                    List <List <LegalEntityBranchAuditView> > legalEntityBranchesHistory = LegalEntityBranchAuditView.GetLegalEntityBranchesAuditView(db, legalEntityPK);
                    ViewBag.legalEntityBranchesHistory = legalEntityBranchesHistory;
                }
            }

            return(View(legalEntityView));
        }
Exemple #16
0
        public ActionResult Index()
        {
            IPhysicalEntitiesRepository    physicalEntitiesRepository    = new PhysicalEntitiesRepository(db);
            PhysicalEntityView             physicalEntityView            = new PhysicalEntityView();
            IContractsRepository           contractsRepository           = new ContractsRepository(db);
            ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(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"] : "PhysicalEntityPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <PhysicalEntityView> physicalEntities = PhysicalEntityView.GetPhysicalEntityView(physicalEntitiesRepository.GetValid())
                                                               .OrderBy(ordering);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                physicalEntities = physicalEntities.Where(c => c.Firstname.Contains(searchString) || c.Lastname.Contains(searchString) || c.OIB.Contains(searchString));
            }

            if (!String.IsNullOrWhiteSpace(Request.QueryString["dateOfBirth"]) && String.IsNullOrWhiteSpace(Request.QueryString["dateOfBirthTo"]))
            {
                DateTime dateOfBirth      = DateTime.ParseExact(Request.QueryString["dateOfBirth"], "dd.MM.yyyy.", null);
                int      dateOfBirthMonth = dateOfBirth.Month;
                int      dateOfBirthDay   = dateOfBirth.Day;

                physicalEntities = physicalEntities.Where(c => c.DateOfBirth.Value.Month == dateOfBirthMonth && c.DateOfBirth.Value.Day == dateOfBirthDay);
            }
            else if (!String.IsNullOrWhiteSpace(Request.QueryString["dateOfBirth"]) && !String.IsNullOrWhiteSpace(Request.QueryString["dateOfBirthTo"]))
            {
                DateTime dateOfBirthFrom      = DateTime.ParseExact(Request.QueryString["dateOfBirth"], "dd.MM.yyyy.", null);
                int      dateOfBirthFromMonth = dateOfBirthFrom.Month;
                int      dateOfBirthFromDay   = dateOfBirthFrom.Day;

                DateTime dateOfBirthTo      = DateTime.ParseExact(Request.QueryString["dateOfBirthTo"], "dd.MM.yyyy.", null);
                int      dateOfBirthToMonth = dateOfBirthTo.Month;
                int      dateOfBirthToDay   = dateOfBirthTo.Day;

                physicalEntities = physicalEntities.Where(c => (c.DateOfBirth.Value.Month >= dateOfBirthFromMonth && c.DateOfBirth.Value.Day >= dateOfBirthFromDay) &&
                                                          (c.DateOfBirth.Value.Month <= dateOfBirthToMonth && c.DateOfBirth.Value.Day <= dateOfBirthToDay));
            }

            physicalEntities = physicalEntities.Page(page, pageSize);

            if (!String.IsNullOrWhiteSpace(Request.QueryString["searchString"]))
            {
                string searchString = Request.QueryString["searchString"].ToString();
                ViewData["numberOfRecords"] = physicalEntitiesRepository.GetValid().Where(c => c.Firstname.Contains(searchString) || c.Lastname.Contains(searchString) || c.OIB.Contains(searchString)).Count();
            }
            else
            {
                ViewData["numberOfRecords"] = physicalEntitiesRepository.GetValid().Count();
            }

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

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("PhysicalEntity?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", physicalEntities.ToList()));
            }
        }
Exemple #17
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);
        }