public ActionResult <Day> AddPlace(string tripId, Place place) { ObjectId _id = ObjectId.Parse(tripId); string id = User.FindFirst(ClaimTypes.NameIdentifier)?.Value; return(_placeService.AddPlace(id, _id, place)); }
public void AddPlace(Place place) { try { Logger.LogNewMessage($"Trying to add new place with name {place.Name}", LogType.INFO); PlaceService.AddPlace(place); Window.Close(); } catch (Exception ex) { Logger.LogNewMessage($"Error occured adding place with name {place.Name}. Message {ex.Message}", LogType.ERROR); } }
public void ThrowArgumentNullExceptionWhenPlaceIsNull() { // Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepository = new Mock <IEfGenericRepository <Place> >(); var service = new PlaceService(mockedRepository.Object, mockedUnitOfWork.Object); // Act var message = Assert.Throws <ArgumentNullException>(() => service.AddPlace(null)); // Assert StringAssert.IsMatch("place", message.ParamName); }
public void CallUnitOfWorkMethodCommitOnce() { // Arrange var mockedUnitOfWork = new Mock <IUnitOfWork>(); var mockedRepository = new Mock <IEfGenericRepository <Place> >(); var service = new PlaceService(mockedRepository.Object, mockedUnitOfWork.Object); var mockedPlace = new Mock <Place>(); // Act service.AddPlace(mockedPlace.Object); // Assert mockedUnitOfWork.Verify(x => x.Commit(), Times.Once); }
public async Task <ActionResult> Add([FromBody] AddPlace place) { try { var result = await _placeService.AddPlace(place); return(Ok(result)); } catch (InvalidOperationException e) { return(BadRequest(e.Message)); } catch (Exception e) { return(BadRequest("Hiba történt: " + e.Message)); } }
private async void Add() { await PlaceService.AddPlace(Place); NavigationService.Navigate(typeof(ListPlacesPage)); }