public async Task <IActionResult> PutApplication([FromRoute] int id, [FromBody] Application application)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != application.Id)
            {
                return(BadRequest());
            }

            //_context.Entry(application).State = EntityState.Modified;
            _context.Application.Update(application);

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ApplicationExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemple #2
0
        public async Task <Point> AddPoint(CreatePointRequest createPointRequest)
        {
            var point = new Point
            {
                Id          = Guid.NewGuid(),
                Description = createPointRequest.Description,
                Name        = createPointRequest.Name,
                ObjectType  = createPointRequest.ObjectType,
                ObjectId    = createPointRequest.ObjectId,
                AssetId     = createPointRequest.AssetId,
                Archive     = createPointRequest.Archive,
                LastUpdated = createPointRequest.LastUpdated,
                AddedBy     = createPointRequest.AddedBy
            };

            if (createPointRequest.DeviceId != null)
            {
                var device = await _MarketPlaceContext.Devices.FindAsync(createPointRequest.DeviceId.Value);

                point.Device = device;
            }
            _MarketPlaceContext.Points.Add(point);
            await _MarketPlaceContext.SaveChangesAsync();

            return(point);
        }
        public async Task <Device> CreateDevice(CreateDeviceRequest createDeviceRequest)
        {
            var device = new Device
            {
                Id = Guid.NewGuid(),
                DeviceIdentifier = createDeviceRequest.DeviceIdentifier,
                IpAddress        = createDeviceRequest.IpAddress,
                Type             = createDeviceRequest.Type,
                ClientId         = createDeviceRequest.ClientId,
                BuildingId       = createDeviceRequest.BuildingId
            };

            _dbContext.Devices.Add(device);
            await _dbContext.SaveChangesAsync();

            return(device);
        }
Exemple #4
0
        public async Task <Trend> AddTrend(CreateTrendRequest createTrendRequest)
        {
            var trend = new Trend
            {
                Id           = Guid.NewGuid(),
                Name         = createTrendRequest.Name,
                Interval     = createTrendRequest.Interval,
                Type         = createTrendRequest.Type,
                DateCreated  = createTrendRequest.DateCreated,
                TimeOut      = createTrendRequest.TimeOut,
                TreadsNumber = createTrendRequest.TreadsNumber
            };

            _MarketPlaceContext.Trends.Add(trend);
            await _MarketPlaceContext.SaveChangesAsync();

            return(trend);
        }