public async Task <IActionResult> CreateNewLocation(NewLocationModel locationModel) { if (ModelState.IsValid == false) { return(ValidationProblem()); } int locationId = await _locationsService.CreateAsync(locationModel); return(Created("api/config/Location", locationId)); }
private static SqlParamsModel GetParams_CreateAsync(NewLocationModel locationModel) { var sqlModel = new SqlParamsModel { Sql = "pkg_locations.p_create_new_location", Parameters = new OracleDynamicParameters() }; sqlModel.Parameters.Add("pi_location_name", locationModel.LocationName, dbType: OracleMappingType.Varchar2, ParameterDirection.Input); sqlModel.Parameters.Add("po_location_id", dbType: OracleMappingType.Int32, direction: ParameterDirection.Output); return(sqlModel); }
public async Task <IActionResult> AddLocation(NewLocationModel model) { var location = new Location { LocationName = model.LocationName, LocationAddress = model.LocationAddress, LocationMapUrl = model.LocationMap }; await _locationService.AddLocation(location); return(RedirectToAction("Index", "Location")); }
public async Task <int> CreateAsync(NewLocationModel locationModel) { var sqlModel = new SqlParamsModel { Sql = "pkg_locations.p_create_new_location", Parameters = new OracleDynamicParameters() }; sqlModel.Parameters.Add("pi_location_name", locationModel.LocationName, dbType: OracleMappingType.Varchar2, ParameterDirection.Input); sqlModel.Parameters.Add("po_location_id", dbType: OracleMappingType.Int32, direction: ParameterDirection.Output); await _dataAccess.ExecuteAsync(sqlModel); int locationId = (int)sqlModel.Parameters.Get <decimal>("po_location_id"); return(locationId); }
public Task <HttpResponseMessage> AddNewLocationAsync(NewLocationModel locationDetails) { return(_http.PostAsJsonAsync(locationBaseUrl, locationDetails)); }
/// <summary> /// Create a new location. /// <para> </para> /// <para>Returns the id of the created location.</para> /// </summary> /// <exception cref="NotUniqueException">The location's name isn't unique.</exception> public int CreateLocation(NewLocationModel vm) { return(CreateResource("api/Location/v1/CreateLocation", vm)); }
public ActionResult Edit(int?locationId, int?organizationId, NewLocationModel locationModel) { var location = GetLocation(locationId, organizationId); if (ModelState.IsValid) { // Google limits number of lookups per day. No reason to waste them. bool needGeocode = location.IsNew || locationModel.AddressLine1 != location.AddressLine1 || (locationModel.AddressLine2 ?? "") != location.AddressLine2 || locationModel.City != location.City || locationModel.State != location.State || locationModel.Country != location.Country; // Admin can edit geocode if the lookup fails. if (!needGeocode && RoleUtils.IsUserServiceAdmin()) { // If they aren't set by admin, then lookup, ... or retry. if ((!locationModel.Latitude.HasValue || locationModel.Latitude == 0) && (!locationModel.Longitude.HasValue || locationModel.Longitude == 0)) { needGeocode = true; } else { // Admin set them manually. So use the edited values, ... or // the same unedited values as before. location.Latitude = locationModel.Latitude; location.Longitude = locationModel.Longitude; } } // this is already set at this point by GetLocation() location.OrganizationId = locationModel.OrganizationId; location.Name = locationModel.Name; location.AddressLine1 = locationModel.AddressLine1; location.AddressLine2 = locationModel.AddressLine2; location.City = locationModel.City; location.State = locationModel.State; location.Country = locationModel.Country; location.PostalCode = locationModel.PostalCode; location.PhoneNumber = locationModel.PhoneNumber; if (needGeocode) { if (GoogleMaps.GetGeocode(location) == null && RoleUtils.IsUserServiceAdmin()) { location.Latitude = locationModel.Latitude; location.Longitude = locationModel.Longitude; } } if (RoleUtils.IsUserServiceAdmin()) { location.IsActive = locationModel.IsActive; } if (location.IsNew) { location.UniqueIdentifier = LocationUtils.CreateUid(); } location.Save(); return(new EmptyResult()); } else { Response.StatusCode = 417; Response.TrySkipIisCustomErrors = true; } return(PartialView(locationModel)); }
public IActionResult Create() { var model = new NewLocationModel(); return(View(model)); }