コード例 #1
0
        public void UpdateFuelConsumptionDetail(FuelConsumptionDetailParams fuelConsumptionDetailParams)
        {
            //check exit fuel consumption detail
            var existFuelConsumptionD = _fuelConsumptionDetailRepository.Query(p => p.OrderD == fuelConsumptionDetailParams.OrderD &
                                                                               p.OrderNo == fuelConsumptionDetailParams.OrderNo &
                                                                               p.DetailNo == fuelConsumptionDetailParams.DetailNo &
                                                                               p.DispatchNo ==
                                                                               fuelConsumptionDetailParams.DispatchNo).FirstOrDefault();

            if (existFuelConsumptionD != null)
            {
                if (string.IsNullOrEmpty(fuelConsumptionDetailParams.IsEmpty) &
                    string.IsNullOrEmpty(fuelConsumptionDetailParams.IsHeavy) &
                    string.IsNullOrEmpty(fuelConsumptionDetailParams.IsSingle) & fuelConsumptionDetailParams.FuelConsumption == 0 &
                    fuelConsumptionDetailParams.UnitPrice == 0 & fuelConsumptionDetailParams.Amount == 0)
                {
                    _fuelConsumptionDetailRepository.Delete(existFuelConsumptionD);
                    SaveFuelConsumptionDetail();
                }
                else
                {
                    existFuelConsumptionD.IsEmpty         = fuelConsumptionDetailParams.IsEmpty;
                    existFuelConsumptionD.IsHeavy         = fuelConsumptionDetailParams.IsHeavy;
                    existFuelConsumptionD.IsSingle        = fuelConsumptionDetailParams.IsSingle;
                    existFuelConsumptionD.Distance        = fuelConsumptionDetailParams.ApproximateDistance;
                    existFuelConsumptionD.FuelConsumption = fuelConsumptionDetailParams.FuelConsumption;
                    existFuelConsumptionD.UnitPrice       = fuelConsumptionDetailParams.UnitPrice;
                    existFuelConsumptionD.Amount          = fuelConsumptionDetailParams.Amount;
                    SaveFuelConsumptionDetail();
                }
            }
            else
            {
                var fuelConsumptionMapped = Mapper.Map <FuelConsumptionDetailParams, FuelConsumption_D>(fuelConsumptionDetailParams);
                fuelConsumptionMapped.Distance = fuelConsumptionDetailParams.ApproximateDistance;
                _fuelConsumptionDetailRepository.Add(fuelConsumptionMapped);
                SaveFuelConsumptionDetail();
            }
        }
コード例 #2
0
        public async Task <IHttpActionResult> Post(FuelConsumptionDetailParams fuelConsumptionDetailParams)
        {
            await Task.Run(() => _fuelConsumptionDetailService.UpdateFuelConsumptionDetail(fuelConsumptionDetailParams));

            return(Ok());
        }