public static bool DeletePlace([ActivityTrigger] int placeId) { var request = new PlaceIdRequest() { Id = placeId }; return(_client.PlacesClient.DeletePlace(request)); }
/// <summary> /// Gets a place by Id /// </summary> /// <param name="request">Place Id</param> /// <returns>Returns an individual Place</returns> /// public Place GetPlace(PlaceIdRequest request) { Place place = null; var response = GetAsync($"places/{request.Id}").Result; if (!response.IsSuccessStatusCode) { return(place); } var responseDate = response.Content.ReadAsStringAsync().Result; place = JsonConvert.DeserializeObject <Place>(responseDate); return(place); }
public static bool DeletePlace([ActivityTrigger] int placeId) { log.Information($"Calling DeletePlace function for Place with Id: {placeId}"); try { var request = new PlaceIdRequest() { Id = placeId }; return(client.PlacesClient.DeletePlace(request)); } catch (Exception ex) { log.Error(ex.Message); return(false); } }
public static Place GetPlace([ActivityTrigger] int placeId) { log.Information($"Calling GetPlace function with palceId : {placeId}"); try { var request = new PlaceIdRequest() { Id = placeId }; return(client.PlacesClient.GetPlace(request)); } catch (Exception ex) { log.Error(ex.Message); return(null); } }
public PlaceResponse GetPlace(PlaceIdRequest request) { using (var db = new EventSourceDbContext(_contextOptions)) { var place = db.Places.Find(request.Id); if (place != null) { return(new PlaceResponse() { Place = place }); } return(new PlaceResponse() { Place = place, Result = false }); } }
public Response DeletePlace(PlaceIdRequest request) { var response = new Response(); using (var db = new EventSourceDbContext(_contextOptions)) { var _place = db.Places.Find(request.Id); if (_place == null) { response.Result = false; return(response); } db.Places.Remove(_place); db.SaveChanges(); return(response); } }
public PlaceResponse GetPlace(PlaceIdRequest request) { var response = new PlaceResponse(); var validator = new Response(); try { validator = new PlaceIdRequestValidator(_placeRepository).Validate(request).ToResponse(); } catch (Exception ex) { _logger.Error(ExceptionMessages.GetPlaceException, ex); response.Result = false; response.Errors.Add(new ResponseError { Name = "GetPlaceException", Error = ExceptionMessages.GetPlaceException }); return(response); } if (!validator.Result) { return new PlaceResponse() { Errors = validator.Errors } } ; try { response = _placeRepository.GetPlace(request); } catch (Exception ex) { _logger.Error(ExceptionMessages.GetPlaceException, ex); response.Result = false; response.Errors.Add(new ResponseError { Name = "GetPlaceException", Error = ExceptionMessages.GetPlaceException }); return(response); } return(response); }
public IActionResult Get(int id) { var request = new PlaceIdRequest { Id = id }; _logger.Information(LoggingMessages.GettingPlaceById(id)); var response = _placeServices.GetPlace(request); if (!response.Result) { return(BadRequest(response.Errors)); } if (response.Place == null) { return(NotFound("Place Not Found.")); } return(Ok(response.Place)); }
public IActionResult Delete(int id) { _logger.Information($"Deleting place with id: {id}"); var request = new PlaceIdRequest() { Id = id }; var response = _placeServices.DeletePlace(request); if (!response.Result) { return(BadRequest(response.Errors)); } if (response.Errors.Count > 0) { return(NotFound(response.Errors)); } return(Ok()); }
/// <summary> /// Deletes an individual Place /// </summary> /// <param name="request"> Place Id </param> /// <returns> Returns true or false </returns> public bool DeletePlace(PlaceIdRequest request) { var response = DeleteAsync($"places/{request.Id}").Result; return(response.IsSuccessStatusCode); }