Example #1
0
        public LocationViewModel SaveDeliveryLocation(LocationViewModel model)
        {
            try
            {
                 if (!ModelState.IsValid)
                {
                    throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest,
                       "Error details"));
                }

                var location = LocationProvider.SaveCurrentLocation(model.Id, model.Longitude, model.Latitude);
                var deliveryLocation = new LocationViewModel()
                {
                    Id = location.Id,
                    Longitude = location.Longitude,
                    Latitude = location.Latitude
                };

                return deliveryLocation;
            }
            catch (Exception e)
            {
                throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.BadRequest, e.Message));
            }
        }
Example #2
0
        public LocationViewModel GetDeliveryLocation(long id)
        {
            var location = LocationProvider.GetLocation(id);

                var model = new LocationViewModel()
                {
                    Latitude = location.Latitude,
                    Longitude = location.Longitude
                };

            return model;
        }