public async Task <ActionResult> DetailsForAdmin(string id) { if (string.IsNullOrWhiteSpace(id)) { return(new HttpNotFoundResult()); } var admin = participantsProcessor.GetAdminById(id); if (admin == null) { return(new HttpNotFoundResult()); } var adminParticipantModel = participantsProcessor.AdminDomainToVM(admin); (var success, var message, var contratList) = await contractsProcessor.GetAllForAdmin(adminParticipantModel); var vm = new DetailsForAdminViewModel { AdminParticipant = new AdminParticipantCreateEditViewModel { Login = AdminToLoginVM(admin) }, ContractList = contratList ?? new List <RentContractDataViewModel>() }; return(View(vm)); }
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); }