Пример #1
0
        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();
            }
        }
Пример #2
0
        public async Task AddAsync(FarmBotPlant farmBotEvent)
        {
            string url = $"{Endpoints.FarmBotPlants}";

            HttpResponseMessage httpResponeMessage = await _httpRequest.PostAsync(url, farmBotEvent);

            httpResponeMessage.EnsureSuccessStatusCode();
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
 public Task UpdateAsync(FarmBotPlant entity)
 {
     throw new NotImplementedException();
 }