public HttpResponseMessage Post([FromBody] EventRequest request)
        {
            var userDevice = _userDeviceService.Get(request.Token, request.DeviceId);

            if (userDevice == null)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.NotFound, string.Format(Constants.ErrorMessages.DeviceNotFound, request.DeviceId)));
            }

            userDevice.State = request.State;
            _userDeviceService.AddorUpdate(userDevice);

            return(Request.CreateResponse(HttpStatusCode.OK));
        }
示例#2
0
        public HttpResponseMessage Post([FromBody] UpdateDevicesRequest request)
        {
            try
            {
                foreach (var device in request.Devices)
                {
                    var userDevice = new UserDevice
                    {
                        Token = request.Token,
                        Id    = device.Id,
                        Name  = device.Name,
                        Type  = device.Type
                    };

                    _userDeviceService.AddorUpdate(userDevice);
                }

                return(Request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception e)
            {
                return(Request.CreateResponse(HttpStatusCode.InternalServerError, e.Message));
            }
        }