Exemplo n.º 1
0
        public async Task <(bool, string, IEnumerable <RentContractDataViewModel>)> GetAllForClient(ClientParticipantListViewModel client)
        {
            bool   success      = true;
            string message      = string.Empty;
            var    contractList = new List <RentContractDataViewModel>().AsEnumerable();

            if (client != null)
            {
                IEnumerable <RentContractModelResponse> bcContractList;
                (success, message, bcContractList) = await bcContracts.GetAllForClient(participantsProcessor.ClientVMToApiModel(client));

                if (success && bcContractList?.Count() > 0)
                {
                    var contractAdminIDList = bcContractList.Select(x => x.GetIDFromAttributedID(x.contractProvider)).ToList();
                    var contractAdmins      = participantsProcessor.GetAllAdmins().Where(x => contractAdminIDList.Contains(x.Id)).ToList();

                    contractList = bcContractList.Select(x => new RentContractDataViewModel
                    {
                        ID = x.contractId,
                        ContractProvider = participantsProcessor.AdminDomainToVM(contractAdmins.Where(cc => cc.Id == x.GetIDFromAttributedID(x.contractProvider)).FirstOrDefault()),
                        ContractClient   = client,
                        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");
        }
Exemplo n.º 3
0
        public ActionResult Admins()
        {
            var admins = participantsProcessor.GetAllAdmins();

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

            PopulateAdminRoles();

            return(View(vm));
        }