public async Task <IActionResult> CreateListing([FromBody] CreateListingRequest request) { int userId = int.Parse(User.Claims.FirstOrDefault(x => x.Type.Equals("UserId")).Value); int listingId = await _listingService.CreateListing(request, userId); return(Ok(new { listingId })); }
public async Task <ActionResult <string> > CreateListing([FromQuery] string listingAsString) { Listing listing = JsonSerializer.Deserialize <Listing>(listingAsString); if (!ModelState.IsValid) { return(BadRequest(ModelState)); } try { string id = await listingService.CreateListing(listing); return(Ok(id)); } catch (Exception e) { Console.WriteLine(e); return(StatusCode(500, e.Message)); } }