public void Get_WithReturnedResults_ReturnsThatResult() { var location = new LocationModel { Postcode = "somewhere" }; _mockLocationRetrievalService.Setup(s => s.Get("anything")).Returns(location); _sut.Get("anything"); Assert.Equal("somewhere", location.Postcode); }
private void lstLocation_TextChanged(object sender, EventArgs e) { if (lstLocation.Text != "") { int locId = Convert.ToInt32(lstLocation.Properties.GetKeyValueByDisplayValue(lstLocation.Text)); LocationModel loc = well.GetLocationDetails(locId); if (loc != null) { txtLatitude.Text = loc.LocLatitude; txtLongitude.Text = loc.LocLongitude; } } }
public async Task <bool> UpdateUserLocationAsync(Guid userId, LocationModel location) { User user = await _repository.GetAsync(userId); if (user == null) { return(false); } (user.Latitude, user.Longitude) = (location.Latitude, location.Longitude); return(await _repository.UpdateAsync(user)); }
public void GetDefaultSettings() { LocationModel MyLoc = new LocationModel(); MyLoc.Id = DefaultValuesModel.CityID; MyLoc.Name = DefaultValuesModel.CityName; MyLoc.Country = DefaultValuesModel.Country; MyLocation = MyLoc; MyFullLocation = MyLocation.FullLocation; RefreshInterval = DefaultValuesModel.RefreshInterval; APIKey = DefaultValuesModel.APIKey; GetDefaultUnits(DefaultValuesModel.Units); }
public async Task <ActionResult> Create([Bind(Include = "LocationID,LocationName,CampusName,LocationDetails")] LocationModel locationModel) { if (ModelState.IsValid) { db.Locations.Add(locationModel); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } ViewBag.CampusName = new SelectList(db.Campuses, "CampusID", "CampusName", locationModel.CampusName); return(View(locationModel)); }
public LocationModel UpdateLocation(LocationModel location) { var loc = Mapper.Map <LocationModel, Data.Graph.Location>(location); var existing = SecurityRepository.GetLocation(location.Id); existing.Name = loc.Name; existing.StaticIpAddress = loc.StaticIpAddress; existing.DefaultAccountId = loc.DefaultAccountId; loc = SecurityRepository.SaveOrUpdateLocation(existing); return(Mapper.Map <Data.Graph.Location, LocationModel>(loc)); }
/// <summary> /// Gets a list of current sublocations /// </summary> /// <param name="gs">The current gamestate</param> /// <returns>All sublocations at this location</returns> public List <Sublocation> GetCurrentSublocations(GameState gs) { LocationModel lm = gs.GetLM(); var subs = lm.GetCurentLocation().GetSublocations().Values; List <Sublocation> sublocations = new List <Sublocation>(); foreach (Sublocation sub in subs) { sublocations.Add(sub); } return(sublocations); }
public void LocationExtensionsClassToLocationModelReturnsObjectWithMileagePropertyWithCorrectChainagePropertyIfMileagePropertyIsNotNull() { Distance testData = _random.NextDistance(new Distance { Mileage = int.MaxValue }); Location testObject = new Location { Mileage = testData }; LocationModel testResult = testObject.ToLocationModel(); Assert.AreEqual(testData.Chainage, testResult.Mileage.Chainage); }
public APIResponseModel <string> Post([FromBody] LocationModel model) { if (string.IsNullOrWhiteSpace(model.Name)) { return(new APIResponseModel <string>( "Cannot insert empty location.", StatusCodes.Status406NotAcceptable.ToString(), StatusCodes.Status406NotAcceptable, "")); } _locationBusinessLogic.Insert(model.Name); return(new APIResponseModel <string>( "Location inserted successfully", StatusCodes.Status200OK.ToString(), StatusCodes.Status200OK, "")); }
public async void UpdateLocation(LatLng loc, int userId) { var loct = new LocationModel { UserId = userId, Lat = loc.Latitude, Lng = loc.Longitude }; var result = await ApiCallService.UpdateRequestAsync(loct, Constants.ApiUrl + "reservation/updatelocation"); var r = result; }
public ActionResult PostByLocation(LocationModel model) { if (ModelState.IsValid) { var location = _mapper.Map <LocationDto>(model); var data = new ApiClient().PostData <LocationDto, List <AreaDto> >("api/area/PostByLocation", location); return(View("Index", _mapper.Map <List <AreaModel> >(data))); } else { return(View("Index", "Home", model)); } }
public IActionResult Location(LocationModel locat) { if (ModelState.IsValid) { var user = TempData["user"].ToString(); TempData["user"] = user; var userD = _ur.Get(user); TempData["location"] = locat.Location; return(View("Create", new PizzaModel())); } return(View(locat)); }
public void CreateLocationId(LocationModel model) { using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString(db))) { var p = new DynamicParameters(); p.Add("@VenueId", model.Venue.Id); p.Add("@VenueAddressId", model.VenueAddress.Id); p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output); connection.Query <StaffModel>("dbo.spCreateLocation", p, commandType: CommandType.StoredProcedure); model.Id = p.Get <int>("@Id"); } }
public XF_LocationNewEdit(LocationModel location) { InitializeComponent(); if (location == null) { throw new ArgumentNullException("location"); } this.ActiveModel = location; this.Load += XF_LocationNewEdit_Load; }
public LocationController(UnitView.Factory unit_factory, Settings settings, LocationModel location_model, SignalBus signal_bus, IInputController input_controller) { this._signal_bus = signal_bus; this._location_model = location_model; this._input_controller = input_controller; this._unit_factory = unit_factory; this._settings = settings; this._camera_bounds = Camera.main.OrthographicBounds(); }
public IActionResult GetLocationByID(int id) { try { LocationModel location = _locationService.GetLocationByID(id); string name = location.Name; return(Ok(location)); } catch (Exception) { return(StatusCode(500)); } }
/// <summary>Delete a location in the database.</summary> /// <param name="locationModel">A Location Model.</summary> public async Task DeleteLocation(LocationModel locationModel) { var location = await _unitOfWork.LocationRepository.GetById(locationModel.LocationId); if (location == null) { throw new KeyNotFoundException("Specified location was not found."); } await _unitOfWork.LocationRepository.Delete(location); await _unitOfWork.Save(); }
public ActionResult Save(LocationModel location) { if (ModelState.IsValid) { try { binder.location.Add(location); binder.SaveChanges(); } catch (Exception e) { } } return(RedirectToAction("Index")); }
public LocationModel MapData(Location l) { LocationModel lm = new LocationModel(); if (l != null) { lm.Id = l.Id; lm.VacationDomain = l.VacationDomain; lm.City = l.City; lm.VacId = l.Vacation.Id; } return(lm); }
public ActionResult FrontDesk() { // ensure we are at a physical location! var currentLocation = UserSession.CurrentLocation; if (currentLocation == null || currentLocation.IsVirtual) { var newLocation = new LocationModel().GetLocations_Physical().First(); UserSession.CurrentLocationGuid = newLocation.LocationGuid; } return(View(new PeopleModel())); }
public async Task <int> SaveLocationAsync(LocationModel location) { var loc = await GetLocationAsync(location.Id); if (loc == null) { return(await database.InsertAsync(location)); } else { return(await database.UpdateAsync(location)); } }
public string GetRecommendation(string country) { /* * Search the database where the model and json provided country are the same * then return the recommendation to the function. */ if (country != null) { _location = _context.Locations.Where(x => x.Country == country).FirstOrDefault(); } return(_location.Recommendation); }
public IActionResult WeatherData(double lat, double lon, LocationModel location) { string prova = "https://api.openweathermap.org/data/2.5/weather?lat=" + lat + "&lon=" + lon + "&units=metric&appid=0770f1c5ab85fe7ddff0cf0e60b1efac"; WeatherData results = _rs.GetWeatherData(prova).Result; /*var currentUser = _userManager.FindByNameAsync(HttpContext.User.Identity.Name).Result; * results.Main.User = currentUser; * results.Main.CityName = results.Title; * _save.SaveAsync(results.Main);*/ return(View(results)); }
/// <summary> /// Sets initial horizontal location of <see cref="T:iTextSharp.text.pdf.PdfPTable" />. /// </summary> /// <param name="table">Table which receives new position.</param> /// <param name="location">Location to apply.</param> /// <returns> /// A <see cref="T:iTextSharp.text.pdf.PdfPTable" /> object which contains specified position. /// </returns> /// <remarks> /// If value of <see cref="P:iTin.Export.Model.LocationModel.Mode"/> is <see cref="iTin.Export.Model.KnownElementLocation.ByCoordenates"/> /// uses the default configuration, the horizontal alignment is set to center and vertical alignment set to top. /// </remarks> public static PdfPTable SetHorizontalLocationFrom(this PdfPTable table, LocationModel location) { var locationType = location.LocationType; if (locationType.Equals(KnownElementLocation.ByCoordenates)) { return(table); } table.HorizontalAlignment = ((AlignmentModel)location.Mode).Horizontal.ToElementHorizontalAlignment(); return(table); }
public RedirectToActionResult Post(string Ip, string Country, string City) { var input = new LocationModel() { ip = Ip, country_name = Country, city = City }; string connString = _config.GetSection("DbConnection").GetSection("ConnectionString").Value.ToString(); var response = _locationService.Add(input, connString); return(RedirectToAction("Index")); }
/// <summary> /// Creates a new instance of <see cref="LocationEditViewModel"/> /// </summary> public LocationEditViewModel(LocationModel locationModel) { _locationModel = new LocationModel(locationModel); _name = _locationModel.Name; if (_locationModel.Tags.Any()) { _tags = String.Join(", ", _locationModel.Tags); } _description = _locationModel.Description; _location = _locationModel.Location; _map = _locationModel.Map; foreach (LocationType locationType in Enum.GetValues(typeof(LocationType))) { _locationTypeOptions.Add(locationType, locationType.ToString()); } _selectedLocationType = _locationTypeOptions.FirstOrDefault(x => x.Key == _locationModel.LocationType); _creator = _locationModel.Creator; foreach (RoomModel roomModel in _locationModel.Rooms) { RoomViewModel roomViewModel = new RoomViewModel(roomModel); roomViewModel.PropertyChanged += RoomViewModel_PropertyChanged; _rooms.Add(roomViewModel); } _rulerNotes = _locationModel.RulerNotes; _traits = _locationModel.Traits; _knownFor = _locationModel.KnownFor; _conflicts = _locationModel.Conflicts; foreach (BuildingModel buildingModel in _locationModel.Buildings) { BuildingViewModel buildingViewModel = new BuildingViewModel(buildingModel); buildingViewModel.PropertyChanged += BuildingViewModel_PropertyChanged; _buildings.Add(buildingViewModel); } _landmarks = _locationModel.Landmarks; _environment = _locationModel.Environment; _weather = _locationModel.Weather; _foodAndWater = _locationModel.FoodAndWater; _hazards = _locationModel.Hazards; _browseMapLocationCommand = new RelayCommand(obj => true, obj => BrowseMapLocation()); _addRoomCommand = new RelayCommand(obj => true, obj => AddRoom()); _deleteRoomCommand = new RelayCommand(obj => true, obj => DeleteRoom(obj as RoomViewModel)); _addBuildingCommand = new RelayCommand(obj => true, obj => AddBuilding()); _deleteBuildingCommand = new RelayCommand(obj => true, obj => DeleteBuilding(obj as BuildingViewModel)); }
private static Location UpdateLocation(DSModel db, KeyBinder key, LocationModel model, Company company = null) { var poco = db.Locations.Where(l => l.LocationID == model.LocationID).FirstOrDefault(); if (poco == null) { throw new ArgumentException("No Location with the specified ID!"); } poco.LocationName = model.LocationName; poco.LocationCode = model.LocationCode; if (company == null) { poco.CompanyID = model.CompanyID; } else { poco.Company = company; } poco.LocationAddress = model.LocationAddress; poco.LocationPhone = model.LocationPhone; poco.LocationFax = model.LocationFax; if (model.ConfirmationContact.IsChanged) { poco.ConfirmationContact = ContactRepository.SaveContact(db, key, model.ConfirmationContact); key.AddKey(poco.ConfirmationContact, model.ConfirmationContact, poco.ConfirmationContact.GetName(p => p.ContactID)); key.AddKey(poco.ConfirmationContact, model, poco.ConfirmationContact.GetName(p => p.ContactID), model.GetName(p => p.ConfirmationContactID)); } if (model.InvoiceContact.IsChanged) { poco.InvoiceContact = ContactRepository.SaveContact(db, key, model.InvoiceContact); key.AddKey(poco.InvoiceContact, model.InvoiceContact, poco.InvoiceContact.GetName(p => p.ContactID)); key.AddKey(poco.InvoiceContact, model, poco.InvoiceContact.GetName(p => p.ContactID), model.GetName(p => p.InvoiceContactID)); } if (model.DispatchContact.IsChanged) { poco.DispatchContact = ContactRepository.SaveContact(db, key, model.DispatchContact); key.AddKey(poco.DispatchContact, model.DispatchContact, poco.DispatchContact.GetName(p => p.ContactID)); key.AddKey(poco.DispatchContact, model, poco.DispatchContact.GetName(p => p.ContactID), model.GetName(p => p.DispatchContactID)); } poco.TravelPay = model.TravelPay; poco.TravelPayName = model.TravelPayName; poco.LunchTime = model.LunchTime; poco.IsEnabled = model.IsEnabled; poco.IncludeConfirmation = model.IncludeConfirmation; return(poco); }
public async Task <LocationModel> Put(int id, [FromBody] LocationModel locationIn) { var location = await _locationRepository.GetLocation(id); if (location == null) { Response.StatusCode = 404; return(null); } location.Name = locationIn.Name; var locationFromDb = await _locationRepository.UpdateLocation(location); return(locationFromDb); }
private ProductLocationModel createProductLocation(CompanyModel company, ProductModel product, LocationModel location, int qtyOnHand) { var model = new ProductLocationModel { CompanyId = company.Id, ProductId = product.Id, LocationId = location.Id, QuantityOnHand = qtyOnHand, SellOnOrder = 0, PurchaseOnOrder = 0 }; return(model); }
public ActionResult Create(LocationModel location) { if (ModelState.IsValid) { string currentUserId = User.Identity.GetUserId(); //Here we are setting the date for the newly created location. location.CreationDate = DateTime.Now; locationRepository.InsertOrUpdate(currentUserId, location); return(RedirectToAction("Index")); } return(View()); }
/** * Get Shippo's locations * @link https://open-api.shippo.vn/api-endpoints/dia-diem#lay-danh-sach-tat-ca-dia-danh * @param param | null * @return Collection * @throws Exception | ShippoSDKException */ public async Task <List <LocationModel> > ReadByParams(LocationModel paramLocationModel = null) { var response = await Api.ReadByParams(paramLocationModel); if (!Is2XxHttpStatus(response.ResponseMessage.StatusCode)) { throw new ShippoSdkException(response.StringContent); } var listLocationModel = JsonConvert.DeserializeObject <ResultModel <List <LocationModel> > >(response.StringContent); return(listLocationModel.Result); }
public void GroupDescription_WithAllPropertiesSet_BuildsCorrectString() { var sut = new LocationModel(); Assert.Equal("", sut.GroupDescription); sut.Postcode = "SO11 1XX"; Assert.Equal("SO11 1XX", sut.GroupDescription); sut.BuildingName = "Some building"; Assert.Equal("SO11 1XX, Some building", sut.GroupDescription); sut.StreetDescription = "Some street"; Assert.Equal("SO11 1XX, Some building, Some street", sut.GroupDescription); sut.Locality = "Southampton"; Assert.Equal("SO11 1XX, Some building, Some street, Southampton", sut.GroupDescription); }
public async Task<DayWeatherModel> GetWeather(DateTime date, LocationModel location = null) { if (_cache == null) { await GetWeatherInfoAsync(location); if (_cache == null) { return null; } } return _cache.FirstOrDefault(p => (p.Date.Day == date.Day && p.Date.Month == date.Month && p.Date.Year == date.Year)); }
public CentreMapRequestMessage(LocationModel location) { Location = location; }
public GeometryModel() { Location = new LocationModel(); }
async public Task<List<DayWeatherModel>> GetWeatherInfoAsync(LocationModel location = null) { await _sl.WaitAsync(); try { if (_cache != null) { return _cache; } _cache = await _weatherLocal.RestoreAsync<List<DayWeatherModel>>(); var json = await GetWeatherInfoStringAsync(); var response = JObject.Parse(json); var days = (JArray)response["response"][0]["periods"]; var localCacheNull = false; foreach (var model in days.Select(day => new DayWeatherModel { Date = (DateTime)day["validTime"], AverageTempuratureC = (double)day["avgTempC"], AverageTempuratureF = (double)day["avgTempF"], MinmaxTempuratureC = (string)day["minTempC"] + "° / " + (string)day["maxTempC"], WeatherCoded = (string)day["weatherPrimaryCoded"] })) { if (_cache == null) { localCacheNull = true; _cache = new List<DayWeatherModel> { model }; } else { if (localCacheNull) { _cache.Add(model); } else { var tempModel = model; var index = _cache.FindIndex(p => (p.Date.Day == tempModel.Date.Day && p.Date.Month == tempModel.Date.Month && p.Date.Year == tempModel.Date.Year)); if (index >= 0) { _cache[index] = model; } else { _cache.Add(model); } } } } await _weatherLocal.SaveAsync(_cache); return _cache; } catch (Exception) { return _cache; } finally { _sl.Release(); } }