public async Task <ActionResult> UpdateGemById(Guid gemId, [FromBody] GemForm gemForm) { var entity = await _gemRepository.GetGemEntityAsync(gemId); if (entity == null) { return(NotFound()); } entity.IconId = gemForm.IconId; entity.Name = gemForm.Name; entity.Address = gemForm.Address; entity.Description = gemForm.Description; entity.Latitude = gemForm.Latitude; entity.Longitude = gemForm.Longitude; entity.Notes = gemForm.Notes; entity.ImageUrl = gemForm.ImageUrl; entity.Website = gemForm.Website; entity.Phone = gemForm.Phone; entity.YelpUrl = gemForm.YelpUrl; entity.GoogleUrl = gemForm.GoogleUrl; entity.MenuUrl = gemForm.MenuUrl; await _gemRepository.UpdateGemAsync(entity); return(NoContent()); }
public async Task <ActionResult> CreateGemForTreasureMapAsync( Guid treasureMapId, [FromBody] GemForm gemForm) { var treasureMap = await _treasureMapRepository.GetTreasureMapAsync(treasureMapId); if (treasureMap == null) { return(NotFound()); } if (gemForm.Latitude == 0 || gemForm.Longitude == 0) { return(BadRequest(new ApiError("Latitude and longitude coordinates are required."))); } var gemId = await _gemRepository.CreateGemAsync( treasureMapId, gemForm.IconId, gemForm.Name, gemForm.Description, gemForm.Address, gemForm.Latitude, gemForm.Longitude, gemForm.Notes, gemForm.ImageUrl, gemForm.Website, gemForm.Phone, gemForm.YelpUrl, gemForm.GoogleUrl, gemForm.MenuUrl); return(Created( Url.Link(nameof(GemsController.GetGemById), new { id = gemId }), gemId)); }