Ejemplo n.º 1
0
        public async Task <BookmarkResponse> SaveAsync(Bookmark bookmark)
        {
            try
            {
                Bookmark bookmarkRequest = await _bookmarkRepository.FindByLatitudeAndLongitude(bookmark.Latitude, bookmark.Longitude);

                if (bookmarkRequest != null)
                {
                    return(new BookmarkResponse("An error ocurred while saving the bookmark: Geolocation is already assigned to an existing Bookmark"));
                }
                await _bookmarkRepository.AddAsync(bookmark);

                await _unitOfWork.CompleteAsync();

                return(new BookmarkResponse(bookmark));
            }
            catch (Exception ex)
            {
                return(new BookmarkResponse($"An error ocurred while saving the bookmark: {ex.Message}"));
            }
        }