public DriveCollectionsViewModel GetDetailsModel(int driveId, int userId) { Require.ThatIntIsPositive(driveId); Require.ThatIntIsPositive(userId); Drive drive = this.drives.GetByIdQueryable(driveId) .Include(d => d.From) .Include(d => d.To) .Include(d => d.Car) .Include(d => d.Driver) .Include(d => d.DrivesPassengers) .FirstOrDefault(); if (drive != null) { DriveDetailsViewModel driveViewModel = mapper.Map <DriveDetailsViewModel>(drive); driveViewModel.ReservedByUser = drive.DrivesPassengers.Any(x => x.PassengerId == userId); driveViewModel.UserIsOwner = drive.DriverId == userId; DriverDetailsViewModel driverViewModel = mapper.Map <DriverDetailsViewModel>(drive.Driver); CarDetailsViewModel carViewModel = mapper.Map <CarDetailsViewModel>(drive.Car); DriveCollectionsViewModel model = new DriveCollectionsViewModel() { Drive = driveViewModel, Driver = driverViewModel, Car = carViewModel }; return(model); } return(null); }
public DriverPage(int driverId) { InitializeComponent(); DriverId = driverId; DataContext = new DriverDetailsViewModel(DriverId, DriverPageDbContext); }
public IActionResult Details(int id) { DriverDetailsViewModel model = new DriverDetailsViewModel { Name = driverRepository.GetDriverByID(id).Name, Age = driverRepository.GetDriverByID(id).Age, Cars = carRepository.GetCars().Where(car => car.DriverID == id) }; return(View(model)); }
/// <summary> /// Initializes a new instance of the <see cref="DriversAndCarsTabItemViewModel"/> class. /// </summary> /// <param name="modalDialogProvider">The modal dialog service.</param> /// <param name="serviceFactory">The service factory.</param> public DriversAndCarsTabItemViewModel(IMainViewModel mainViewModel, IModalDialogProvider modalDialogProvider, IServiceFactory serviceFactory) : base(mainViewModel, modalDialogProvider, serviceFactory) { CarDetailsViewModel = new CarDetailsViewModel(MainViewModel, ModalDialogProvider, ServiceFactory); CarListViewModel = new CarListViewModel(MainViewModel, CarDetailsViewModel, ModalDialogProvider, ServiceFactory); DriverDetailsViewModel = new DriverDetailsViewModel(MainViewModel, ModalDialogProvider, ServiceFactory); DriverListViewModel = new DriverListViewModel(MainViewModel, DriverDetailsViewModel, ModalDialogProvider, ServiceFactory); ViewModelProvider.RegisterChildViewModel(CarDetailsViewModel, ViewModelProviderAction.IsReadOnlyChanged | ViewModelProviderAction.SaveInvoked); ViewModelProvider.RegisterChildViewModel(DriverDetailsViewModel, ViewModelProviderAction.IsReadOnlyChanged | ViewModelProviderAction.SaveInvoked); ViewModelProvider.RegisterChildViewModel(CarListViewModel, ViewModelProviderAction.DeleteInvoked); ViewModelProvider.RegisterChildViewModel(DriverListViewModel, ViewModelProviderAction.DeleteInvoked); ViewModelProvider.ChildrenViewModelDeleteInvoked += new System.EventHandler<ViewModelProviderActionEventArgs>(ViewModelProvider_ChildrenViewModelDeleteInvoked); ViewModelProvider.ChildrenViewModelSaveInvoked += new System.EventHandler<ViewModelProviderActionEventArgs>(ViewModelProvider_ChildrenViewModelSaveInvoked); }
public ActionResult ViewDetails(long id) { try { DriverDetailsViewModel model; Driver driver = new Driver(id); var vehicle = driver.GetVehicle(); if (vehicle != null) { model = new DriverDetailsViewModel { Balance = driver.Balance, CNIC = driver.CNIC_Number, ContactNumber = driver.ContactNumber.LocalFormatedPhoneNumber, CreditLimit = driver.CreditLimit, Id = driver.UserId, IsBlocked = driver.IsBlocked, Name = driver.FullName.FirstName + " " + driver.FullName.LastName, Rating = decimal.Round(driver.TotalRating, 2), RegisterationNumber = vehicle.RegisterationNumber.FormattedNumber, RidesCompleted = driver.GetCompletedRides().Count, VehcileType = vehicle.Type.Name, VehicleModel = vehicle.Model, IsActive = driver.IsActive, LastLocation = driver.LastLocation }; } else { model = new DriverDetailsViewModel { Balance = driver.Balance, CNIC = driver.CNIC_Number, ContactNumber = driver.ContactNumber.LocalFormatedPhoneNumber, CreditLimit = driver.CreditLimit, Id = driver.UserId, IsBlocked = driver.IsBlocked, Name = driver.FullName.FirstName + " " + driver.FullName.LastName, Rating = decimal.Round(driver.TotalRating, 2), RegisterationNumber = null, RidesCompleted = driver.GetCompletedRides().Count, VehcileType = null, VehicleModel = null, IsActive = driver.IsActive, LastLocation = driver.LastLocation }; } model.Comments = new List <ZATAppApi.Models.Common.RatingAndComments>(); foreach (var item in driver.GetRatingAndComments()) { model.Comments.Add(new ZATAppApi.Models.Common.RatingAndComments { Comment = item.Comment, Rating = item.Rating, Rider = item.Rider }); } model.ManualTransactions = new List <ManualTransactionViewModel>(50); foreach (var item in driver.GetManualTransactions()) { model.ManualTransactions.Add(new ManualTransactionViewModel { Amount = decimal.Round(item.Amount, 2), Time = UISupportiveFunctions.GetPassedTimeSpanFromNow(item.TransactionDateTime) }); } model.MobileTransactions = new List <MobileTransactionsViewModel>(); foreach (var item in driver.GetAllMobileAccountTransactions()) { if (item.IsVerified) { model.MobileTransactions.Add(new MobileTransactionsViewModel { Amount = decimal.Round(item.Amount, 2), IsVerified = item.IsVerified, ReferenceNumber = item.ReferenceNumber, ServiceName = item.MobileAccountServiceProviderName, Time = UISupportiveFunctions.GetPassedTimeSpanFromNow(item.TransactionRegisteredTime) }); } } return(View(model)); } catch (Exception ex) { return(RedirectToAction("ErrorPage", "Error", ex)); } }