Пример #1
0
        public async Task <IActionResult> Create([FromBody] DroneNetworkSettingsViewModel dronenetworksettings)
        {
            if (dronenetworksettings == null)
            {
                return(BadRequest());
            }

            var id = await _dronenetworksettingsServiceAsync.Add(dronenetworksettings);

            return(Created($"api/DroneNetworkSettings/{id}", id));  //HTTP201 Resource created
        }
Пример #2
0
        public async Task <IActionResult> Update(int id, [FromBody] DroneNetworkSettingsViewModel dronenetworksettings)
        {
            if (dronenetworksettings == null || dronenetworksettings.Id != id)
            {
                return(BadRequest());
            }

            var retVal = await _dronenetworksettingsServiceAsync.Update(dronenetworksettings);

            if (retVal == 0)
            {
                return(StatusCode(304));                 //Not Modified
            }
            else if (retVal == -1)
            {
                return(StatusCode(412, "DbUpdateConcurrencyException"));  //412 Precondition Failed  - concurrency
            }
            else
            {
                return(Accepted(dronenetworksettings));
            }
        }