Example #1
0
        public async Task <ResponseBase> AddBookmarkAsync(AddBookmarkRequest request)
        {
            var response = new ResponseBase();

            request.UserId = _userProvider.GetUserId();

            var entity    = _bookmarkMapper.ToEntity(request);
            var isSuccess = await _bookmarkRepository.AddAsync(entity);

            if (!isSuccess)
            {
                response.StatusCode = (int)HttpStatusCode.InternalServerError;
            }

            return(response);
        }
        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}"));
            }
        }