Skip to content

Instantly share code, notes, and snippets.

@ahmetkucukoglu
Last active February 12, 2020 20:44
Show Gist options
  • Select an option

  • Save ahmetkucukoglu/eb12a93840331ca4281fae376762be93 to your computer and use it in GitHub Desktop.

Select an option

Save ahmetkucukoglu/eb12a93840331ca4281fae376762be93 to your computer and use it in GitHub Desktop.
ASP.NET Core ile Couchbase GeoSearch - EventsController.cs
namespace Couchbase.GeoSearchApp.Controllers
{
using Couchbase.Core;
using Couchbase.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Threading.Tasks;
[Route("api/[controller]")]
[ApiController]
public class EventsController : ControllerBase
{
private readonly IBucket _bucket;
public EventsController(IBucketProvider bucketProvider)
{
_bucket = bucketProvider.GetBucket("events");
}
[HttpPost]
public async Task<IActionResult> CreateEvent([FromBody] CreateEventRequest request)
{
var document = new Document<EventDocument>
{
Id = Guid.NewGuid().ToString(),
Content = new EventDocument
{
Subject = request.Subject,
Description = request.Description,
Date = request.Date,
Address = request.Address,
Location = new EventLocationDocument
{
Lat = request.Latitude,
Lon = request.Longitude
}
}
};
await _bucket.InsertAsync(document);
return Ok();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment