コード例 #1
0
        public async Task <IActionResult> Create(Plant plant)
        {
            await _plantService.Create(plant).ConfigureAwait(false);

            var statusCode = new StatusCodeResult(200);

            return(statusCode);
        }
コード例 #2
0
        // POST: api/Plant
        public async Task <IHttpActionResult> Post(PlantModel plant)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            var userId = await UserService.GetUserId(User.Identity.Name);

            var plantDTO = new PlantDTO
            {
                Name = plant.Name,
                ApplicationUserId = userId
            };
            await PlantService.Create(plantDTO);

            return(Ok());
        }
コード例 #3
0
 public Plant Post([FromBody] Plant camera)
 {
     return(_plantService.Create(camera));
 }
コード例 #4
0
 public ActionResult <Plant> Create(Plant plant)
 {
     _plantService.Create(plant);
     return(CreatedAtRoute("GetPlant", new { id = plant.Id.ToString() }, plant));
 }
コード例 #5
0
ファイル: LabFarmController.cs プロジェクト: MattZK/iot18-lf1
 public Plant PostCamera([FromBody] Plant plant, int id)
 {
     plant.Labfarm = _labfarmService.GetById(id);
     return(_plantService.Create(plant));
 }