Beispiel #1
0
        public IActionResult PutDeviceCode(string key, [FromBody] Models.ConData.DeviceCode newItem)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (newItem == null || (newItem.UserCode != key))
                {
                    return(BadRequest());
                }

                this.OnDeviceCodeUpdated(newItem);
                this.context.DeviceCodes.Update(newItem);
                this.context.SaveChanges();

                var itemToReturn = this.context.DeviceCodes.Where(i => i.UserCode == key);
                this.OnAfterDeviceCodeUpdated(newItem);
                return(new ObjectResult(SingleResult.Create(itemToReturn)));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Beispiel #2
0
        public IActionResult Post([FromBody] Models.ConData.DeviceCode item)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(ModelState));
                }

                if (item == null)
                {
                    return(BadRequest());
                }

                this.OnDeviceCodeCreated(item);
                this.context.DeviceCodes.Add(item);
                this.context.SaveChanges();

                return(Created($"odata/ConData/DeviceCodes/{item.UserCode}", item));
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", ex.Message);
                return(BadRequest(ModelState));
            }
        }
Beispiel #3
0
 partial void OnAfterDeviceCodeUpdated(Models.ConData.DeviceCode item);
Beispiel #4
0
 partial void OnDeviceCodeDeleted(Models.ConData.DeviceCode item);
Beispiel #5
0
 partial void OnDeviceCodeCreated(Models.ConData.DeviceCode item);