Ejemplo n.º 1
0
        public async Task <(bool, string, IEnumerable <RentContractDataViewModel>)> GetAllForAdmin(AdminParticipantListViewModel admin)
        {
            bool   success      = true;
            string message      = string.Empty;
            var    contractList = new List <RentContractDataViewModel>().AsEnumerable();

            if (admin != null)
            {
                IEnumerable <RentContractModelResponse> bcContractList;
                (success, message, bcContractList) = await bcContracts.GetAllForAdmin(participantsProcessor.AdminVMToApiModel(admin));

                if (success && bcContractList?.Count() > 0)
                {
                    var contractClientIDList = bcContractList.Select(x => x.GetIDFromAttributedID(x.contractClient)).ToList();
                    var contractClients      = participantsProcessor.GetAllClients().Where(x => contractClientIDList.Contains(x.Id)).ToList();

                    contractList = bcContractList.Select(x => new RentContractDataViewModel
                    {
                        ID = x.contractId,
                        ContractProvider = admin,
                        ContractClient   = participantsProcessor.ClientDomainToVM(contractClients.Where(cc => cc.Id == x.GetIDFromAttributedID(x.contractClient)).FirstOrDefault()),
                        ExpiryDate       = x.expiryDate,
                        DurationDays     = x.durationDays,
                        Status           = x.status,
                        Content          = x.content
                    });
                }
            }

            return(success, message, contractList);
        }
        private void PopulateViewBag(ContractDetailsViewModel vm, string participantId = "")
        {
            var admins = participantsProcessor.GetAllAdmins().Select(x => new SelectListItem {
                Text = x.ApplicationUser.UserName, Value = x.Id, Selected = x.Id == participantId
            }).ToList();

            ViewBag.Admins = new SelectList(admins, "Value", "Text");
            if (string.IsNullOrWhiteSpace(vm.Contract.ContractProvider.ID))
            {
                vm.Contract.ContractProvider.ID = admins.Where(x => x.Selected).Select(x => x.Value).FirstOrDefault();
            }

            var clients = participantsProcessor.GetAllClients().Select(x => new SelectListItem {
                Text = x.ApplicationUser.UserName, Value = x.Id, Selected = x.Id == participantId
            }).ToList();

            ViewBag.Clients = new SelectList(clients, "Value", "Text");
            if (string.IsNullOrWhiteSpace(vm.Contract.ContractClient.ID))
            {
                vm.Contract.ContractClient.ID = clients.Where(x => x.Selected).Select(x => x.Value).FirstOrDefault();
            }

            var statuses = Enum.GetNames(typeof(Core.LogicConstants.RentContractStatus)).Select(x => new SelectListItem {
                Text = x, Value = x
            }).ToList();

            ViewBag.Statuses = new SelectList(statuses, "Value", "Text");
        }
Ejemplo n.º 3
0
        public ActionResult Clients()
        {
            var clients = participantsProcessor.GetAllClients();

            var vm = clients.Select(x => new ClientParticipantListViewModel
            {
                ID   = x.Id,
                Name = x.ApplicationUser.UserName
            }).ToList();

            PopulateClientRoles();

            return(View(vm));
        }