예제 #1
0
        public static void Map(LMYFrameWorkMVCEntities dbContext, Driver src, DriverModel dest)
        {
            if (src == null || dest == null)
            {
                return;
            }

            dest.CopyPropertyValues(src);

            dest.StartDateString = src.StartDate.ToStringDateFormat();

            foreach (Truck truck in src.Trucks)
            {
                TruckModel truckModel = new TruckModel();
                truckModel.CopyPropertyValues(truck);
                dest.TruckModels.Add(truckModel);
            }
        }
예제 #2
0
        public static void Map(LMYFrameWorkMVCEntities dbContext, Truck src, TruckModel dest)
        {
            if (src == null || dest == null)
            {
                return;
            }

            dest.CopyPropertyValues(src);

            dest.OnBuyDateString = src.OnBuyDate.ToStringDateFormat();

            if (src.Driver != null)
            {
                dest.DriverModel.CopyPropertyValues(src.Driver);
            }

            Nullable <double> truckExpensesCosts = src.TruckExpenses.Where(x => x.Price != null).Sum(x => x.Price);
            Nullable <double> truckLoadsIncome   = src.TruckLoads.Where(x => x.TotalIncome != null && x.StatusId == Lookups.TruckLoadStatus.Completed).Sum(x => x.TotalIncome);

            dest.TotalCosts  = src.OnBuyExpenses + (truckExpensesCosts == null ? 0 : (double)truckExpensesCosts);
            dest.TotalIncome = (truckLoadsIncome == null ? 0 : (double)truckLoadsIncome);
            dest.TotalProfit = dest.TotalIncome - dest.TotalCosts;
        }