public Result <PlaceInfo> CreatePlace(NewPlace newPlace) { if (newPlace == null) { return(Result <PlaceInfo> .NewFailure($"{nameof(newPlace)} is NULL.")); } if (newPlace.PlaceType == PlaceType.Unknown) { return(Result <PlaceInfo> .NewFailure($"{nameof(newPlace.PlaceType)} == {PlaceType.Unknown}.")); } if (string.IsNullOrWhiteSpace(newPlace.PlaceCode)) { return(Result <PlaceInfo> .NewFailure($"{nameof(newPlace.PlaceCode)} is Null/Empty/Whitespace.")); } var storagePlace = _mapper.Map <StorageNewPlace>(newPlace); var resultNewPlaceId = _placesStorage.CreatePlace(storagePlace); if (resultNewPlaceId.Success) { _cache.InvalidateAll(); var maybeNewPlace = GetPlace(resultNewPlaceId.Value); return(maybeNewPlace.ToResult()); } else { return(Result <PlaceInfo> .NewFailure(resultNewPlaceId.ErrorMessage)); } }
public async Task <IActionResult> OnPostAsync() { string[] data; data = NewPlace.Split(';'); otter.LocationId = int.Parse(data[0]); otter.PlaceName = data[1]; _context.Attach(otter).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!VydraExists(otter.TattooID)) { return(NotFound()); } else { throw; } } return(RedirectToPage("../Index")); }
private async void btnChange_Click(object sender, RoutedEventArgs e) { int new_floor, new_room, new_room_id; try { new_floor = int.Parse(txtNewFloor.Text); new_room = int.Parse(txtNewRoom.Text); using (IUnitOfWork unitOfWork = App.kernel.Get <IUnitOfWork>()) { new_room_id = unitOfWork.RoomTypes.GetRoomTypeId( comboNewRoomType.SelectedItem.ToString() ); NewPlace place = new NewPlace { NewFloor = new_floor, NewRoom = new_room, NewRoomTypeId = new_room_id }; unitOfWork.ChangeRoom( _person, place, AppSettings.Admin, AppSettings.DormId ); unitOfWork.Complete(); } await this.ShowMessageAsync("OK", _surname + " " + _name + " " + "переехал(-а) из " + _room + " в " + new_room); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void InitCountries() { Countries = new BindingList <Country>(CountryService.GetAll()); if (NewPlace.IsValid()) { NewPlace.Country = Countries.First(x => x.Id == NewPlace.Country.Id); //Necessary because initial value in combo box is not set. //Initial value must reference one of the collections members } }
internal static async Task <Place> CreatePlace(IWimdioApiClient client) { var random = Guid.NewGuid().ToString().Split('-').First(); var place = new NewPlace { Name = $"Name {random}", Description = $"Description {random}" }; return(await client.CreatePlace(place)); }
public async Task <NewPlace> GetMyPlaceDetails(string placeId) { NewPlace result = null; using (var httpClient = CreateClient()) { var response = await httpClient.GetAsync($"api/place/details/json?placeid={Uri.EscapeUriString(placeId)}&key={_googleMapsKey}").ConfigureAwait(false); if (response.IsSuccessStatusCode) { var json = await response.Content.ReadAsStringAsync().ConfigureAwait(false); if (!string.IsNullOrWhiteSpace(json) && json != "ERROR") { result = new NewPlace(JObject.Parse(json)); } } } return(result); }