Пример #1
0
        public ActionResult Add(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);
                LegalEntityLegalRepresentative             legalEntityLegalRepresentative            = new LegalEntityLegalRepresentative();

                legalEntityLegalRepresentativeView.ConvertTo(legalEntityLegalRepresentativeView, legalEntityLegalRepresentative);

                legalEntityLegalRepresentativesRepository.Add(legalEntityLegalRepresentative);
                legalEntityLegalRepresentativesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK);

                if (TempData["legalEntityFK"] != null)
                {
                    return(RedirectToAction("Index", "LegalEntity"));
                }
                else
                {
                    return(RedirectToAction("Index", "LegalEntityLegalRepresentative"));
                }
            }
            else
            {
                legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db);

                return(View(legalEntityLegalRepresentativeView));
            }
        }
Пример #2
0
        public ActionResult Delete(int?legalEntityLegalRepresentativePK)
        {
            ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);

            if (legalEntityLegalRepresentativePK != null)
            {
                LegalEntityLegalRepresentative legalEntityLegalRepresentative = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativePK);

                legalEntityLegalRepresentative.Deleted = true;

                legalEntityLegalRepresentativesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Пример #3
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()));
            }
        }
Пример #4
0
        public ActionResult Edit(int?legalEntityLegalRepresentativePK)
        {
            if (legalEntityLegalRepresentativePK != null)
            {
                ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);
                LegalEntityLegalRepresentative             legalEntityLegalRepresentative            = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativePK);
                LegalEntityLegalRepresentativeView         legalEntityLegalRepresentativeView        = new LegalEntityLegalRepresentativeView();

                legalEntityLegalRepresentativeView.ConvertFrom(legalEntityLegalRepresentative, legalEntityLegalRepresentativeView, db);
                legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db);

                return(View(legalEntityLegalRepresentativeView));
            }
            else
            {
                return(RedirectToAction("Index", "LegalEntityLegalRepresentative"));
            }
        }
Пример #5
0
        public static List <List <LegalEntityLegalRepresentativeAuditView> > GetLegalEntityLegalRepresentativesAuditView(ObjectContext context, int legalEntityFK)
        {
            ILegalEntitiesRepository    legalEntitiesRepository    = new LegalEntitiesRepository(context);
            IPhysicalEntitiesRepository physicalEntitiesRepository = new PhysicalEntitiesRepository(context);
            ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(context);

            // get all legalEntity branches
            List <LegalEntityLegalRepresentativeView> legalEntityLegalRepresentatives = LegalEntityLegalRepresentativeView.GetLegalEntityLegalRepresentativeView(legalEntityLegalRepresentativesRepository.GetAll(), legalEntitiesRepository.GetValid(), physicalEntitiesRepository.GetValid())
                                                                                        .Where(c => c.LegalEntityFK == legalEntityFK)
                                                                                        .ToList();

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

            foreach (LegalEntityLegalRepresentativeView legalEntityLegalRepresentative in legalEntityLegalRepresentatives)
            {
                legalEntityLegalRepresentativesListList.Add(LegalEntityLegalRepresentativeAuditView.GetLegalEntityLegalRepresentativeAuditView(context, legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK));
            }

            return(legalEntityLegalRepresentativesListList);
        }
Пример #6
0
        public ActionResult Edit(LegalEntityLegalRepresentativeView legalEntityLegalRepresentativeView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);
                LegalEntityLegalRepresentative             legalEntityLegalRepresentative            = legalEntityLegalRepresentativesRepository.GetLegalEntityLegalRepresentativeByPK((int)legalEntityLegalRepresentativeView.LegalEntityLegalRepresentativePK);
                legalEntityLegalRepresentativeView.ConvertTo(legalEntityLegalRepresentativeView, legalEntityLegalRepresentative);

                legalEntityLegalRepresentativesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityLegalRepresentative.LegalEntityLegalRepresentativePK);

                return(RedirectToAction("Index", "LegalEntityLegalRepresentative"));
            }
            else
            {
                legalEntityLegalRepresentativeView.BindDDLs(legalEntityLegalRepresentativeView, db);

                return(View(legalEntityLegalRepresentativeView));
            }
        }
Пример #7
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));
        }
Пример #8
0
        public ActionResult Index()
        {
            ILegalEntitiesRepository       legalEntitiesRepository       = new LegalEntitiesRepository(db);
            IContractsRepository           contractsRepository           = new ContractsRepository(db);
            ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
            IBanksRepository            banksRepository = new BanksRepository(db);
            ILegalEntityBanksRepository legalEntitiesBanksRepository = new LegalEntityBanksRepository(db);
            ILegalEntityLegalRepresentativesRepository legalEntityLegalRepresentativesRepository = new LegalEntityLegalRepresentativesRepository(db);
            ILegalEntityOwnersRepository legalEntityOwnersRepository = new LegalEntityOwnersRepository(db);
            IAssessmentsRepository       assessmentsRepository       = new AssessmentsRepository(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"] : "LegalEntityPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <LegalEntityView> legalEntities = LegalEntityView.GetLegalEntityView(legalEntitiesRepository.GetValid(),
                                                                                            legalEntityBranchesRepository.GetValid(),
                                                                                            contractsRepository.GetValid(),
                                                                                            banksRepository.GetValid(),
                                                                                            legalEntitiesBanksRepository.GetValid(),
                                                                                            legalEntityLegalRepresentativesRepository.GetValid(),
                                                                                            legalEntityOwnersRepository.GetValid(),
                                                                                            assessmentsRepository.GetValid())
                                                         .OrderBy(ordering);

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

            if (!String.IsNullOrWhiteSpace(Request.QueryString["company"]) && Request.QueryString["company"].Contains("true"))
            {
                legalEntities = legalEntities.Where(c => c.Company == true);
            }

            if (String.IsNullOrWhiteSpace(Request.QueryString["active"]))
            {
                legalEntities = legalEntities.Where(c => c.Active == true);
            }
            else
            {
                var active = Request.QueryString["active"].Contains("true");
                legalEntities = legalEntities.Where(c => c.Active == active);
            }

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

            legalEntities = legalEntities.Page(page, pageSize);

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

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("LegalEntity?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", legalEntities.ToList()));
            }
        }