示例#1
0
        public ActionResult Add(LegalEntityBranchView legalEntityBranchView, FormCollection form, int?legalEntityFK)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch legalEntityBranch = new LegalEntityBranch();

                legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch);

                legalEntityBranchesRepository.Add(legalEntityBranch);
                legalEntityBranchesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("INSERT", legalEntityBranch.LegalEntityBranchPK);

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

                return(View(legalEntityBranchView));
            }
        }
示例#2
0
        public ActionResult Index()
        {
            ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
            ILegalEntitiesRepository       legalEntitiesRepository       = new LegalEntitiesRepository(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"] : "LegalEntityBranchPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IQueryable <LegalEntityBranchView> branches = LegalEntityBranchView.GetLegalEntityBranchView(legalEntityBranchesRepository.GetValid(), legalEntitiesRepository.GetValidLegalEntities())
                                                          .OrderBy(ordering);

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

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

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

            branches = branches.Page(page, pageSize);

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

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

            if (page > numberOfPages)
            {
                string url = LinkHelper.getQueryStringArray(new string[] { "page" });
                return(Redirect("LegalEntityBranch?" + url + "page=" + numberOfPages));
            }
            else
            {
                return(View("Index", branches.ToList()));
            }
        }
示例#3
0
        public ActionResult Edit(int?legalEntityBranchPK)
        {
            if (legalEntityBranchPK != null)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch     branch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchPK);
                LegalEntityBranchView legalEntityBranchView = new LegalEntityBranchView();

                legalEntityBranchView.ConvertFrom(branch, legalEntityBranchView, db);
                legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

                return(View(legalEntityBranchView));
            }
            else
            {
                return(RedirectToAction("Index", "LegalEntityBranch"));
            }
        }
示例#4
0
        public static List <List <LegalEntityBranchAuditView> > GetLegalEntityBranchesAuditView(ObjectContext context, int legalEntityFK)
        {
            ILegalEntitiesRepository       legalEntitiesRepository = new LegalEntitiesRepository(context);
            ILegalEntityBranchesRepository legalEntityLegalEntityBranchesRepository = new LegalEntityBranchesRepository(context);

            // get all legalEntity legalEntityBranches
            List <LegalEntityBranchView> legalEntityBranchesList = LegalEntityBranchView.GetLegalEntityBranchView(legalEntityLegalEntityBranchesRepository.GetAll(), legalEntitiesRepository.GetValid())
                                                                   .Where(c => c.LegalEntityFK == legalEntityFK)
                                                                   .ToList();

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

            foreach (LegalEntityBranchView legalEntityBranch in legalEntityBranchesList)
            {
                LegalEntityBranchesListList.Add(LegalEntityBranchAuditView.GetLegalEntityBranchAuditView(context, legalEntityBranch.LegalEntityBranchPK));
            }

            return(LegalEntityBranchesListList);
        }
示例#5
0
        public ActionResult Add(int?legalEntityFK)
        {
            LegalEntityBranchView legalEntityBranchView = new LegalEntityBranchView();

            // set default country to Croatia
            legalEntityBranchView.CountryFK = 81;

            //legalEntities ddl
            ILegalEntitiesRepository legalEntitiesRepository = new LegalEntitiesRepository(db);

            if (legalEntityFK != null)
            {
                TempData["legalEntityFK"]             = legalEntityFK;
                legalEntityBranchView.LegalEntityFK   = (int)legalEntityFK;
                legalEntityBranchView.LegalEntityName = legalEntitiesRepository.GetLegalEntityByPK((int)legalEntityFK).Name;
            }

            legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

            return(View(legalEntityBranchView));
        }
示例#6
0
        public ActionResult Edit(LegalEntityBranchView legalEntityBranchView, FormCollection form)
        {
            if (ModelState.IsValid)
            {
                ILegalEntityBranchesRepository legalEntityBranchesRepository = new LegalEntityBranchesRepository(db);
                LegalEntityBranch legalEntityBranch = legalEntityBranchesRepository.GetLegalEntityBranchByPK((int)legalEntityBranchView.LegalEntityBranchPK);
                legalEntityBranchView.ConvertTo(legalEntityBranchView, legalEntityBranch);

                legalEntityBranchesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", legalEntityBranch.LegalEntityBranchPK);

                return(RedirectToAction("Index", "LegalEntityBranch"));
            }
            else
            {
                legalEntityBranchView.BindDDLs(legalEntityBranchView, db);

                return(View(legalEntityBranchView));
            }
        }
示例#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));
        }