Exemplo n.º 1
0
 public object Calculate(Order order)
 {
     if (order != null)
     {
         return new { Price = 250 };
     }
     return new { Price = 100 };
 }
Exemplo n.º 2
0
        public Order Create(OrderDto dto)
        {
            var coordsFrom = new GeoCoordinates
            {
                Latitude = Convert.ToDouble(dto.GeoCoordinatesFromLat),
                Longitude = Convert.ToDouble(dto.GeoCoordinatesFromLng)
            };

            //var addressFrom = Db.Addresses.FirstOrDefault(a => a.Coords == coordsFrom);

            var coordsTo = new GeoCoordinates
            {
                Latitude = Convert.ToDouble(dto.GeoCoordinatesToLat),
                Longitude = Convert.ToDouble(dto.GeoCoordinatesToLng)
            };

            //var addressTo = Db.Addresses.FirstOrDefault(a => a.Coords == coordsTo);

            var client = String.IsNullOrEmpty(dto.ClientId) ? null : Db.Clients.FirstOrDefault(c => c.Id == dto.ClientId);

            var order = new Order
            {
                AddressFrom = new Address   //addressFrom ?? new Address
                {
                    Coords = coordsFrom,
                    Name = dto.AddressFrom
                },
                AddressTo = new Address    //addressTo ?? new Address
                {
                    Coords = coordsFrom,
                    Name = dto.AddressFrom
                },
                Client = client,

            };

            return order;
        }