public async Task <IActionResult> Edit(int id, [Bind("Id,AddressLine1,AddressLine2,City,State,PostalCode,AddressShortCode")] LocationAddress locationAddress) { if (id != locationAddress.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(locationAddress); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LocationAddressExists(locationAddress.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(locationAddress)); }
private SelectListItem CreateListItem(LocationAddress location) { string dropdownText = $"{ location.PostalCode }, { location.Street}"; SelectListItem selectLocation = new SelectListItem(dropdownText, location.Id.ToString()); return(selectLocation); }
public async Task <LocationAddress> GetLocationAddress(double latitude, double longitude) { var geoCoder = new Geocoder(Android.App.Application.Context); var addresses = await geoCoder.GetFromLocationAsync(latitude, longitude, 1); if (addresses.Any()) { var address = addresses.First(); var location = new LocationAddress() { Name = address.FeatureName, City = address.Locality, Province = address.AdminArea, ZipCode = address.PostalCode, CountryCode = address.CountryCode.ToLower(), Country = $"{address.CountryName} ({address.CountryCode})", Address = address.MaxAddressLineIndex > 0 ? address.GetAddressLine(0) : string.Empty }; return(location); } return(null); }
private void UpdateDisplayLocation(LocationAddress locationAddress) { if (_txtLocation != null) { _txtLocation.Text = locationAddress?.GetDisplayLocality() ?? string.Empty; } }
public async Task <LocationAddress> ReverseGeoCodeLatLonAsync(double lat, double lon) { var geo = new Geocoder(Forms.Context); var ispresent = Geocoder.IsPresent; IList <Address> addresses = null; do { addresses = await geo.GetFromLocationAsync(lat, lon, 1); } while (!addresses.Any()); if (addresses.Any()) { var place = new LocationAddress(); var add = addresses[0]; place.Name = add.FeatureName; if (add.MaxAddressLineIndex > 0) { place.Address1 = add.GetAddressLine(0); } place.City = add.Locality; place.Province = add.AdminArea; place.ZipCode = add.PostalCode; place.Country = add.CountryCode; return(place); } return(null); }
public bool CreateSupplier(AddressBook addressBook, EmailEntity emailEntity, LocationAddress locationAddress) { try { AddressBook .CreateSupplierAddressBook(addressBook, emailEntity) .Apply(); Task <AddressBook> addressBookLookupTask = Task.Run(async() => await AddressBook.Query().GetAddressBookbyEmail(emailEntity.Email)); locationAddress.AddressId = addressBookLookupTask.Result.AddressId; LocationAddress .AddLocationAddress(locationAddress) .Apply(); Email.CreateSupplierEmail(addressBook.AddressId, emailEntity).Apply(); Supplier supplier = new Supplier { AddressId = addressBook.AddressId, Identification = emailEntity.Email }; Supplier .AddSupplier(supplier) .Apply(); return(true); } catch (Exception ex) { throw new Exception("CreateSupplier", ex); } }
public IActionResult AddLocation([FromForm] NewLocationViewModel locationData) { if (!ModelState.IsValid || locationData == null) { return(PartialView("_AddLocationPartial", locationData)); } try { var customer = customerService.GetCustomerById(locationData.CustomerId); var newLocation = LocationAddress.Create( locationData.Country, locationData.City, locationData.Street, locationData.StreetNumber, locationData.PostalCode); customerService.AddLocationToCustomer(customer.Id, newLocation); return(PartialView("_AddLocationPartial", locationData)); } catch (CustomerNotFoundException notFound) { logger.LogError("Failed to find the customer entity {@Exception}", notFound.Message); logger.LogDebug("Failed to find the customer entity {@ExceptionMessage}", notFound); return(BadRequest("Failed to find user")); } catch (Exception e) { logger.LogError("Failed to add a new Location {@Exception}", e.Message); logger.LogDebug("Failed to add a new Location {@ExceptionMessage}", e); return(BadRequest("Failed to create a new Location")); } }
public async Task <LocationAddress> GetLocationAddress(double latitude, double longitude) { var geoCoder = new CLGeocoder(); var place = new CLLocation(latitude, longitude); var placemarks = await geoCoder.ReverseGeocodeLocationAsync(place); if (placemarks.Any()) { var placeMark = placemarks.First(); var location = new LocationAddress() { Name = placeMark.Name, City = placeMark.Locality, Province = placeMark.AdministrativeArea, ZipCode = placeMark.PostalCode, Country = $"{placeMark.Country} ({placeMark.IsoCountryCode})", Address = new CNPostalAddressFormatter().StringFor(placeMark.PostalAddress) }; return(location); } return(null); }
public async Task <LocationAddress> GetLocationAddress(double latitude, double longitude) { MapService.ServiceToken = "create-a-key-at-www.bingmapsportal.com"; var geoPosition = new BasicGeoposition() { Latitude = latitude, Longitude = longitude }; var geoPoint = new Geopoint(geoPosition); var place = await MapLocationFinder.FindLocationsAtAsync(geoPoint); if (place.Status == MapLocationFinderStatus.Success) { var mapLocation = place.Locations.First(); var mapAddress = mapLocation.Address; var location = new LocationAddress() { Name = mapLocation.DisplayName, City = mapAddress.Town, Province = mapAddress.Region, ZipCode = mapAddress.PostCode, Country = $"{mapAddress.Country} ({mapAddress.CountryCode})", Address = $"{mapAddress.Street} {mapAddress.StreetNumber}", }; return(location); } return(null); }
private void OnAddressItemClick(object sender, LocationAddress e) { try { if (_settings == null) { throw new ArgumentNullException(nameof(_settings)); } if (!ValidateAddress(e)) { return; } _settings.UseTrackCurrentLocation = false; _settings.LocationAddress = e; AppSettings.Default.SaveAppWidgetSettings(_settings); var intent = new Intent(); intent.PutExtra(ExtraLocationChanged, true); SetResult(Result.Ok, intent); Finish(); } catch (Exception ex) { Log.Error(ex); ShowError(Resource.String.InternalError); } }
public void AddLocationToCustomer(Guid customerId, LocationAddress locationAddress) { var customer = GetById(customerId); dbContext.LocationAddresses.Add(locationAddress); customer.AddLocationAddress(locationAddress); dbContext.SaveChanges(); }
private async Task <LocationAddressView> MapToLocationAddressView(LocationAddress inputObject) { Mapper mapper = new Mapper(); LocationAddressView outObject = mapper.Map <LocationAddressView>(inputObject); await Task.Yield(); return(outObject); }
public Order CreateOrder(Recipient recipient, Customer sender, LocationAddress deliveryAddress, LocationAddress pickUpAddress, decimal price) { var order = Order.Create(recipient, sender, pickUpAddress, deliveryAddress, price); OrderRepository.Add(order); PersistenceContext.SaveChanges(); return(order); }
public async Task <IActionResult> DeleteLocationAddress([FromBody] LocationAddressView view) { LocationAddressModule invMod = new LocationAddressModule(); LocationAddress locationAddress = await invMod.LocationAddress.Query().MapToEntity(view); invMod.LocationAddress.DeleteLocationAddress(locationAddress).Apply(); return(Ok(view)); }
public override void MapLocationAddressEntity(ref LocationAddress locationAddress, LocationAddressView view) { locationAddress.AddressId = view.AddressId; locationAddress.Address_Line_1 = view.Address_Line1; locationAddress.City = view.City; locationAddress.State = view.State; locationAddress.Country = view.Country; locationAddress.Zipcode = view.Zipcode; locationAddress.TypeXRefId = view.TypeXRefId; }
//Get Location Address public Address GetLocationAddress(int locationId) { LocationAddress locationAddress = new LocationAddress(); locationAddress = db.LocationAddresses.SingleOrDefault(c => c.LocationId == locationId); if (locationAddress != null) { return(db.Addresses.SingleOrDefault(c => c.AddressId == locationAddress.AddressId)); } return(null); }
public async Task <IActionResult> Create([Bind("Id,AddressLine1,AddressLine2,City,State,PostalCode,AddressShortCode")] LocationAddress locationAddress) { if (ModelState.IsValid) { _context.Add(locationAddress); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(locationAddress)); }
public async Task <LocationAddress> ReverseLocationAsync(double lat, double lng) { var geoCoder = new CLGeocoder(); var location = new CLLocation(lat, lng); var placemarks = await geoCoder.ReverseGeocodeLocationAsync(location); var place = new LocationAddress(); var pm = placemarks[0]; place.City = pm.AdministrativeArea; return(place); }
public LocationAddressView(LocationAddress locationAddress) { this.Address_Line1 = locationAddress.Address_Line_1; this.Address_Line2 = locationAddress.Address_Line_2; this.City = locationAddress.City; this.State = locationAddress.State; this.Zipcode = locationAddress.Zipcode; this.AddressId = locationAddress.AddressId; this.Country = locationAddress.Country; this.TypeXRefId = locationAddress.TypeXRefId; this.Type = locationAddress.UDC.Value; }
public (double, double) GetLatLongForLocation(LocationAddress location) { EnsureArg.IsNotNull(location, nameof(location)); EnsureArg.IsNotNullOrWhiteSpace(location.Street, nameof(location.Street)); // etc // do something to get the real cooridnates var longitude = GetRandomNumber(-180, 180); var latitude = GetRandomNumber(-90, 90); return(longitude, latitude); }
public void Initialize() { try { string value = ExtraProperties["address"].ToString(); LocationAddress address = JsonConvert.DeserializeObject <LocationAddress>(value); address.Id = Id.ToString(); this.SetProperty("address", address); } catch (Exception ex) { } }
public IActionResult SetCurrentLocation([FromBody] SetCurrentLocationRequest currentLocationRequest) { // make sure it's valid if (currentLocationRequest.UserId == 0) { return(this.BadRequest()); } // check other params are valid // make sure it's authorised to do what it's trying if (currentLocationRequest.UserId < 0) { return(this.Forbid()); } // map the address into something the service knows about - automapper var locationAddress = new LocationAddress { Street = currentLocationRequest.CurrentLocation.AddressLine1, Town = currentLocationRequest.CurrentLocation.Town, PostCode = currentLocationRequest.CurrentLocation.PostCode, Country = currentLocationRequest.CurrentLocation.Country }; var currLoc = this._geolocationService.GetLatLongForLocation(locationAddress); var userLoc = new UserLocation { UserId = currentLocationRequest.UserId, Longitude = currLoc.Item1, Latitude = currLoc.Item2, Area = currentLocationRequest.Area }; var savedSuccessfully = this._locationDataAccess.SetCurrentLocation(userLoc); if (savedSuccessfully) { return(this.CreatedAtAction( "GetCurrentLocationForUser", new { id = userLoc.UserId }, userLoc)); } this.ModelState.AddModelError("SetCurrentLocation", "Something went wrong trying to save the current location"); var badRequestResponse = new BadRequestResponse(this.ModelState); return(this.BadRequest(badRequestResponse)); }
public async Task <IActionResult> UpdateLocationAddress([FromBody] LocationAddressView view) { LocationAddressModule invMod = new LocationAddressModule(); LocationAddress locationAddress = await invMod.LocationAddress.Query().MapToEntity(view); invMod.LocationAddress.UpdateLocationAddress(locationAddress).Apply(); LocationAddressView retView = await invMod.LocationAddress.Query().GetViewById(locationAddress.LocationAddressId); return(Ok(retView)); }
public IActionResult NewOrder([FromForm] NewOrderViewModel orderData) { try { var sender = customerService.GetCustomerById(orderData.SenderId); if (orderData.PickupLocationId == null && orderData.DeliveryLocationId == null) { return(PartialView("_NewOrderPartial", orderData)); } if (orderData.PickupLocationId == null || orderData.DeliveryLocationId == null) { var bonusLocation = LocationAddress.Create(orderData.NewLocation.Country, orderData.NewLocation.City, orderData.NewLocation.Street, orderData.NewLocation.StreetNumber, orderData.NewLocation.PostalCode); customerService.AddLocationToCustomer(sender.Id, bonusLocation); if (orderData.PickupLocationId == null) { orderData.PickupLocationId = bonusLocation.Id.ToString(); } if (orderData.DeliveryLocationId == null) { orderData.DeliveryLocationId = bonusLocation.Id.ToString(); } } var recipient = orderService.CreateNewRecipient(orderData.RecipientName, orderData.RecipientPhoneNo, orderData.RecipientEmail); orderService.CreateOrder(recipient, sender, orderData.PickupLocationId, orderData.DeliveryLocationId, orderData.Price); return(PartialView("_NewOrderPartial", orderData)); } catch (Exception e) { logger.LogError("Failed to create a new Order {@Exception}", e.Message); logger.LogDebug("Failed to create a new Order {@ExceptionMessage}", e); return(BadRequest(e.Message)); } }
public async Task <IActionResult> OnPostLocationTemplate() { try { if (ModelState.IsValid) { LocationTemplate_Dto location = JsonSerializer.Deserialize <LocationTemplate_Dto>(Request.Form["info"]); LocationAddress address = JsonSerializer.Deserialize <LocationAddress>(Request.Form["address"]); location.SetProperty("address", address); bool IsEditing = location.Id != Guid.Empty; if (IsEditing) { LocationTemplate curLocation = await LocationTemplateAppService.Repository.GetAsync(location.Id); curLocation.LocationName = location.LocationName; curLocation.LocationNameLocalized = location.LocationNameLocalized; curLocation.LocationCode = location.LocationCode; curLocation.Status = location.Status; curLocation.LocationCountryId = location.LocationCountryId; curLocation.LocationEmail = location.LocationEmail; curLocation.LocationFax = location.LocationFax; curLocation.LocationMobile = location.LocationMobile; curLocation.LocationPhone = location.LocationPhone; curLocation.LocationCountry = null; curLocation.UpdateExtraProperties(location.ExtraProperties); LocationTemplate_Dto updated = ObjectMapper.Map <LocationTemplate, LocationTemplate_Dto>(await LocationTemplateAppService.Repository.UpdateAsync(curLocation)); updated.LocationCountry = ObjectMapper.Map <DictionaryValue, DictionaryValue_Dto>(await DictionaryValuesRepo.GetAsync(x => x.Id == updated.LocationCountryId)); return(StatusCode(200, updated)); } else { location.Id = Guid.Empty; LocationTemplate_Dto added = await LocationTemplateAppService.CreateAsync(location); added.LocationCountry = ObjectMapper.Map <DictionaryValue, DictionaryValue_Dto>(await DictionaryValuesRepo.GetAsync(x => x.Id == added.LocationCountryId)); return(StatusCode(200, added)); } } } catch (Exception ex) { } return(StatusCode(500)); }
public async Task <LocationAddress> ReverseLocationAsync(double lat, double lng) { var geo = new Geocoder(Android.App.Application.Context, Locale.Default); var addresses = await geo.GetFromLocationAsync(lat, lng, 1); if (addresses.Any()) { var place = new LocationAddress(); var add = addresses[0]; place.City = add.Locality; place.Province = add.AdminArea; return(place); } return(null); }
public async Task <IActionResult> AddLocationAddress([FromBody] LocationAddressView view) { LocationAddressModule invMod = new LocationAddressModule(); NextNumber nnLocationAddress = await invMod.LocationAddress.Query().GetNextNumber(); view.LocationAddressNumber = nnLocationAddress.NextNumberValue; LocationAddress locationAddress = await invMod.LocationAddress.Query().MapToEntity(view); invMod.LocationAddress.AddLocationAddress(locationAddress).Apply(); LocationAddressView newView = await invMod.LocationAddress.Query().GetViewByNumber(view.LocationAddressNumber); return(Ok(newView)); }
/// <inheritdoc/> public string ToDelimitedString() { CultureInfo culture = CultureInfo.CurrentCulture; return(string.Format( culture, StringHelper.StringFormatSequence(0, 9, Configuration.FieldSeparator), Id, PrimaryKeyValueLoc?.ToDelimitedString(), LocationDescription, LocationTypeLoc != null ? string.Join(Configuration.FieldRepeatSeparator, LocationTypeLoc) : null, OrganizationNameLoc?.ToDelimitedString(), LocationAddress?.ToDelimitedString(), LocationPhone != null ? string.Join(Configuration.FieldRepeatSeparator, LocationPhone.Select(x => x.ToDelimitedString())) : null, LicenseNumber != null ? string.Join(Configuration.FieldRepeatSeparator, LicenseNumber.Select(x => x.ToDelimitedString())) : null, LocationEquipment != null ? string.Join(Configuration.FieldRepeatSeparator, LocationEquipment) : null ).TrimEnd(Configuration.FieldSeparator.ToCharArray())); }
public async Task TestAddUpdatDelete() { LocationAddressModule LocationAddressMod = new LocationAddressModule(); AddressBook addressBook = await LocationAddressMod.AddressBook.Query().GetEntityById(1); Udc udc = await LocationAddressMod.Udc.Query().GetEntityById(60); LocationAddressView view = new LocationAddressView() { AddressLine1 = "123 abc", City = "Boise", Zipcode = "83709", TypeXrefId = udc.XrefId, Type = udc.Value, AddressId = addressBook.AddressId, Name = addressBook.Name, State = "ID", Country = "USA" }; NextNumber nnNextNumber = await LocationAddressMod.LocationAddress.Query().GetNextNumber(); view.LocationAddressNumber = nnNextNumber.NextNumberValue; LocationAddress locationAddress = await LocationAddressMod.LocationAddress.Query().MapToEntity(view); LocationAddressMod.LocationAddress.AddLocationAddress(locationAddress).Apply(); LocationAddress newLocationAddress = await LocationAddressMod.LocationAddress.Query().GetEntityByNumber(view.LocationAddressNumber); Assert.NotNull(newLocationAddress); newLocationAddress.Type = "Residence Update"; LocationAddressMod.LocationAddress.UpdateLocationAddress(newLocationAddress).Apply(); LocationAddressView updateView = await LocationAddressMod.LocationAddress.Query().GetViewById(newLocationAddress.LocationAddressId); Assert.Same(updateView.Type, "Residence Update"); LocationAddressMod.LocationAddress.DeleteLocationAddress(newLocationAddress).Apply(); LocationAddress lookupLocationAddress = await LocationAddressMod.LocationAddress.Query().GetEntityById(view.LocationAddressId); Assert.Null(lookupLocationAddress); }
public IFluentLocationAddress CreateSupplierLocationAddress(long addressId, LocationAddress locationAddress) { locationAddress.AddressId = addressId; Task <IList <LocationAddress> > locationAddressListTask = Task.Run(async() => await unitOfWork.locationAddressRepository.GetEntitiesByAddressId(addressId)); Task.WaitAll(locationAddressListTask); if (locationAddressListTask.Result == null) { AddLocationAddress(locationAddress); return(this as IFluentLocationAddress); } processStatus = CreateProcessStatus.AlreadyExists; return(this as IFluentLocationAddress); }
/// <summary> /// The revise location address. /// </summary> /// <param name="locationAddress"> /// The location address. /// </param> public virtual void ReviseLocationAddress(LocationAddress locationAddress) { Check.IsNotNull(locationAddress, () => LocationAddress); DomainRuleEngine.CreateRuleEngine<Location, LocationAddress> ( Location, () => ReviseLocationAddress ) .WithContext ( locationAddress ) .WithContext ( this ) .Execute(() => { LocationAddress = locationAddress; }); }
/// <summary> /// Initializes a new instance of the <see cref="LocationAddressAndPhone"/> class. /// </summary> /// <param name="locationAddress"> /// The location address. /// </param> protected internal LocationAddressAndPhone(LocationAddress locationAddress) : this() { Check.IsNotNull(locationAddress, () => LocationAddress); }
/// <summary> /// The add address and phone. /// </summary> /// <param name="locationAddress"> /// The location address. /// </param> /// <returns> /// A LocationAddressAndPhone. /// </returns> public virtual LocationAddressAndPhone AddAddressAndPhone(LocationAddress locationAddress) { Check.IsNotNull(locationAddress, "locationAddress is required."); LocationAddressAndPhone locationAddressAndPhone = null; var createdLocationAddressAndPhone = new LocationAddressAndPhone ( locationAddress ); DomainRuleEngine.CreateRuleEngine ( this, "AddAddressAndPhoneRuleSet" ) .WithContext ( createdLocationAddressAndPhone ) .Execute(() => { locationAddressAndPhone = createdLocationAddressAndPhone; locationAddressAndPhone.Location = this; _locationAddressesAndPhones.Add(locationAddressAndPhone); NotifyItemAdded(() => LocationAddressesAndPhones, locationAddressAndPhone); }); return locationAddressAndPhone; }