public ActionResult Delete(Guid id) { try { // Get farmbot plant FarmBotPlant farmBotPlantToRemove = _farmBotPlantsRepository .FirstOrDefault(e => e.PlantId == id); // Check if (farmBotPlantToRemove == null) return NotFound(); // Remove _farmBotPlantsRepository.Remove(farmBotPlantToRemove); // Save _farmBotDbContext.SaveChanges(); // Return result return NoContent(); } catch { return BadRequest(); } }
public async Task AddAsync(FarmBotPlant farmBotEvent) { string url = $"{Endpoints.FarmBotPlants}"; HttpResponseMessage httpResponeMessage = await _httpRequest.PostAsync(url, farmBotEvent); httpResponeMessage.EnsureSuccessStatusCode(); }
public ActionResult<Event> Post([FromBody] FarmBotPlant farmBotPlant) { try { // Check model if (!ModelState.IsValid) return BadRequest(ModelState); // Add _farmBotPlantsRepository.Add(farmBotPlant); // Save _farmBotDbContext.SaveChanges(); // Return result return CreatedAtAction(nameof(Get), farmBotPlant); } catch { return BadRequest(ModelState); } }
public Task UpdateAsync(FarmBotPlant entity) { throw new NotImplementedException(); }