public async Task <ActionResult <Plant> > Post([FromBody] Plant plant) { try { // Check model if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Add _plantRepository.Add(plant); // Save _farmBotDbContext.SaveChanges(); // Notify //await _communicationHubContext.Clients.All.ReceiveMessage("", $"{plant.Name} plant created"); // Return result return(CreatedAtAction(nameof(Get), plant)); } catch { return(BadRequest(ModelState)); } }
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 ActionResult <Parameters> Post([FromBody] Parameters parameters) { try { // Check model if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Add _parametersRepository.Add(parameters); // Save _farmBotDbContext.SaveChanges(); // Return result return(CreatedAtAction(nameof(Get), parameters)); } catch { return(BadRequest(ModelState)); } }
public ActionResult <Event> Post([FromBody] Event farmBotEvent) { try { // Check model if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Add _eventRepository.Add(farmBotEvent); // Save _farmBotDbContext.SaveChanges(); // Return result return(CreatedAtAction(nameof(Get), new { id = farmBotEvent.Id }, farmBotEvent)); } catch { return(BadRequest(ModelState)); } }
public ActionResult <FarmBot> Post([FromBody] FarmBot FarmBot) { try { // Check model if (!ModelState.IsValid) { return(BadRequest(ModelState)); } // Add _farmBotRepository.Add(FarmBot); // Save _farmBotDbContext.SaveChanges(); // Return result return(CreatedAtAction(nameof(Get), FarmBot)); } catch { return(BadRequest(ModelState)); } }