コード例 #1
0
        /// <summary>
        /// Calculates the DMV all.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        public DmvCalculation CalculateDmvAll(DmvCalculation dmvCalculation)
        {
            decimal co2ExhaustTaxRate = this.GetTaxRateForTheGivenCo2Exhaust(
                dmvCalculation.Co2EmissionsValue, dmvCalculation.EnginePowerKw, dmvCalculation.FuelTypeId,
                dmvCalculation.VehicleTypeId, dmvCalculation.AtLeastEightSeatsVehicle, dmvCalculation.EuroExhaustTypeId);

            decimal euroExhaustAdditionalTaxRate = this.GetAdditionalTaxRateBasedonEuroExhaust(dmvCalculation.EuroExhaustTypeId, dmvCalculation.VehicleTypeId);

            decimal displacementAdditionalTaxRate = this.GetTaxRateForAdditionalDisplacementSize(dmvCalculation.EngineDisplacementCcm, dmvCalculation.VehicleTypeId);

            decimal specialAdditionalTaxRate = this.GetSpecialTaxRateAdditionally(
                dmvCalculation.DieselParticlesAbove005Limit, dmvCalculation.FuelTypeId, dmvCalculation.VehicleTypeId, dmvCalculation.EngineTypeId);

            // Tax calculationss
            dmvCalculation.BaseTaxRate = (double)(co2ExhaustTaxRate + euroExhaustAdditionalTaxRate + specialAdditionalTaxRate) / 100;

            dmvCalculation.BaseTaxRateValue = dmvCalculation.BaseTaxRate * dmvCalculation.VehicleValue;

            dmvCalculation.AdditionalTaxRate = (double)displacementAdditionalTaxRate / 100;

            dmvCalculation.AdditionalTaxRateValue = dmvCalculation.AdditionalTaxRate * dmvCalculation.VehicleValue;

            dmvCalculation.TaxTotalValue = dmvCalculation.BaseTaxRateValue + dmvCalculation.AdditionalTaxRateValue;

            // Other
            dmvCalculation.UserId = ServiceLocator.Instance.Resolve <IUserProvider>().GetCurrentUserId();

            return(dmvCalculation);
        }
コード例 #2
0
        /// <summary>
        /// Posts the specified DMV calculation.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        public async Task <HttpResponseMessage> Post(DmvCalculation dmvCalculation)
        {
            DmvCalculationResult dmvCalculationResult = await _dmvCalculationManager.ProcessDmvTaxValueResult(dmvCalculation);

            HttpResponseMessage httpResponseMessage = base.GetHttpResponseMessage(dmvCalculationResult);

            return(httpResponseMessage);
        }
コード例 #3
0
        /// <summary>
        /// Gets the specified identifier.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <returns></returns>
        public Domain.DmvCalculation Get(int id)
        {
            DmvCalculation dmvCalculationDb = null;

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Include("MobileDeCar").Where(c => c.IsDeleted == false && c.Id == id).FirstOrDefault();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }
コード例 #4
0
        /// <summary>
        /// Saves the specified DMV calculation.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public async Task <Domain.DmvCalculation> Save(Domain.DmvCalculation dmvCalculation)
        {
            DmvCalculation dmvCalculationDb = Mapper.Map <DmvCalculation>(dmvCalculation);

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Add(dmvCalculationDb);

                await db.SaveChangesAsync();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }
コード例 #5
0
        /// <summary>
        /// Updates the specified DMV calculation.
        /// </summary>
        /// <param name="dmvCalculation">The DMV calculation.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public async Task <Domain.DmvCalculation> Update(Domain.DmvCalculation dmvCalculation)
        {
            DmvCalculation dmvCalculationDb = Mapper.Map <DmvCalculation>(dmvCalculation);

            using (DmvEntities db = new DmvEntities())
            {
                dmvCalculationDb = db.DmvCalculation.Attach(dmvCalculationDb);

                DbEntityEntry <DmvCalculation> entry = db.Entry(dmvCalculationDb);

                entry.State = EntityState.Modified;
                //entry.Property(e => e.MobileDeCarId).IsModified = true;

                await db.SaveChangesAsync();
            }

            Domain.DmvCalculation dmvCalculationEntity = Mapper.Map <Domain.DmvCalculation>(dmvCalculationDb);

            return(dmvCalculationEntity);
        }
コード例 #6
0
 public DmvCalculationResponse GetDmvTaxValueResult(DmvCalculation dmvCalculation)
 {
     throw new NotImplementedException();
 }
コード例 #7
0
 public DmvCalculationResult(DmvCalculation dmvCalculation, MobileDeCar mobileDeCar) : this(dmvCalculation)
 {
     this.MobileDeCar = mobileDeCar;
 }
コード例 #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DmvCalculationResult"/> class.
 /// </summary>
 /// <param name="dmvCalculation">The DMV calculation.</param>
 public DmvCalculationResult(DmvCalculation dmvCalculation)
 {
     this.DmvCalculation = dmvCalculation;
     this.MobileDeCar    = dmvCalculation.MobileDeCar;
 }
コード例 #9
0
 // PUT api/<controller>/5
 public void Put(int id, DmvCalculation dmvCalculation)
 {
 }