예제 #1
0
        public async Task <ActionResult> DetailsForClient(string id)
        {
            if (string.IsNullOrWhiteSpace(id))
            {
                return(new HttpNotFoundResult());
            }

            var client = participantsProcessor.GetClientById(id);

            if (client == null)
            {
                return(new HttpNotFoundResult());
            }

            var clientParticipantModel = participantsProcessor.ClientDomainToVM(client);

            (var success, var message, var contratList) = await contractsProcessor.GetAllForClient(clientParticipantModel);

            var vm = new DetailsForClientViewModel
            {
                ClientParticipant = new ClientParticipantCreateEditViewModel
                {
                    Login = ClientToLoginVM(client)
                },
                ContractList = contratList ?? new List <RentContractDataViewModel>()
            };

            return(View(vm));
        }
예제 #2
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);
        }