public void Update(ShipmentCostDto item, bool save = true)
        {
            try
            {
                // Get existing Category object from database
                ShipmentCost oldItem = GetFromModel().FirstOrDefault(x => x.Id.Equals(item.Id));

                // Set the new values for the fetched Category object
                if (oldItem != null)
                {
                    oldItem.Cost                    = item.Cost;
                    oldItem.DepartureCity           = item.DepartureCity;
                    oldItem.DestinationCity         = item.DestinationCity;
                    oldItem.DateOfAddedShipmentCost = PersianDateTime.Now.ToString();

                    if (save)
                    {
                        this.Context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public ShipmentCost MapModelToDto(ShipmentCost model)
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <ShipmentCost, ShipmentCostDto>();
                cfg.CreateMap <ShipmentMethod, ShipmentMethodDto>();
            });
            var mapper = config.CreateMapper();

            return(mapper.Map <ShipmentCost>(model));
        }
Beispiel #3
0
        public async Task Create(ShipmentCostDto shipmentItem)
        {
            var id = Guid.Parse(shipmentItem.City);
            var city = _cityRepository.FirstOrDefault(e => e.Id == id);
            var item = new ShipmentCost
            {
                City = city ,
                CreationTime = DateTime.Now,
                CreatorUser = _userRepository.Get(AbpSession.GetUserId()),
                CreatorUserId = AbpSession.GetUserId(),
                Expedition = shipmentItem.Expedition,
                Type = shipmentItem.Type,
                FirstKilo = shipmentItem.FirstKilo,
                NextKilo = shipmentItem.NextKilo,
                KiloQuantity = shipmentItem.KiloQuantity
            };

            await _shipmentRepository.InsertAsync(item);
        }
        public void Delete(ShipmentCostDto item, bool save = true)
        {
            try
            {
                // Get existing model object from database
                ShipmentCost oldItem = GetFromModel().FirstOrDefault(c => c.Id.Equals(item.Id));

                if (oldItem != null)
                {
                    Context.ShipmentCosts.Remove(oldItem);
                }

                if (save)
                {
                    Context.SaveChanges();
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public virtual decimal calculateFinalRate()
        {
            decimal finalRate = Rate;

            if (Insurance != null && BigDecimalMath.cmp(Insurance, BigDecimalMath.ZERO) > 0)
            {
                finalRate = finalRate + Insurance;
            }

            if (Material != null && BigDecimalMath.cmp(Material, BigDecimalMath.ZERO) > 0)
            {
                finalRate = finalRate + Material;
            }
            if (IndirectCost != null && BigDecimalMath.cmp(IndirectCost, BigDecimalMath.ZERO) > 0)
            {
                finalRate = finalRate + IndirectRate;
            }

            if (ShipmentCost != null && BigDecimalMath.cmp(ShipmentCost, BigDecimalMath.ZERO) > 0)
            {
                double qty = Quantity.doubleValue();
                if (qty == 0)
                {
                    qty = 1;
                }
                double fRate = ShipmentCost.doubleValue() / qty;
                finalRate = Rate + (new BigDecimalFixed("" + fRate));
            }

            if (Factor1 != null && BigDecimalMath.cmp(Factor1, BigDecimalMath.ZERO) > 0)
            {
                finalRate = BigDecimalMath.mult(finalRate, Factor1);
            }

            finalRate = finalRate.setScale(10, decimal.ROUND_HALF_UP);
            //		o_map.put("finalRate",finalRate);
            return(finalRate);
        }