示例#1
0
        public async Task <ActionResult <SensordataInsertDto> > PostIoTTemperatures([FromBody] SensordataInsertDto sensordataInsertDto)
        {
            if (sensordataInsertDto == null)
            {
                return(BadRequest());
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            Sensordata addSensordata = Mapper.Map <Sensordata>(sensordataInsertDto);

            _context.Sensordatas.Add(addSensordata);
            await _context.SaveChangesAsync();

            Sensordata newTemperature = await _context.Sensordatas
                                        .FirstOrDefaultAsync(sd => sd.Id == addSensordata.Id);

            return(CreatedAtRoute(
                       routeName: "GetIoTTemperature",
                       routeValues: new { id = newTemperature.Id },
                       value: Mapper.Map <SensordataDto>(newTemperature)));
        }
        public async Task <ActionResult <SpiderpigDto> > PutSpiderpigObservation(int id, [FromBody] SpiderpigDto spiderpigObservation)
        {
            var updateSpiderpigObservation = await _context.Spiderpigs
                                             .FirstOrDefaultAsync(sd => sd.Id == id);

            if (updateSpiderpigObservation == null)
            {
                return(NotFound());
            }

            updateSpiderpigObservation.BuildingId = spiderpigObservation.BuildingId;
            updateSpiderpigObservation.Glasses    = spiderpigObservation.Glasses;
            updateSpiderpigObservation.Friendly   = spiderpigObservation.Friendly;

            _context.Entry(updateSpiderpigObservation).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#3
0
        public async Task <ActionResult <IncidentDto> > PutShitHappen(int id, [FromBody] IncidentDto incident)
        {
            var updateShitHappen = await _context.Incidents
                                   .FirstOrDefaultAsync(sd => sd.Id == id);

            if (updateShitHappen == null)
            {
                return(NotFound());
            }

            updateShitHappen.Temperature = incident.Temperature;
            updateShitHappen.Responsible = incident.Responsible;
            updateShitHappen.Location    = incident.Location;
            updateShitHappen.Status      = incident.Status;
            updateShitHappen.Date        = incident.Date;

            _context.Entry(updateShitHappen).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#4
0
        public async Task <ActionResult <PersonDto> > PutSecretLair(int id, [FromBody] PersonDto secretNSAFile)
        {
            var updateNSAFile = await _context.Persons
                                .Include(l => l.Location)
                                .FirstOrDefaultAsync(sd => sd.Id == id);

            if (updateNSAFile == null)
            {
                return(NotFound());
            }

            updateNSAFile.FirstName = secretNSAFile.FirstName;
            updateNSAFile.LastName  = secretNSAFile.LastName;
            updateNSAFile.Email     = secretNSAFile.Email;
            //updateNSAFile.Location. = secretLair.Position.Lat;
            //updateNSAFile.Position.Lng = secretLair.Position.Lng;

            _context.Entry(updateNSAFile).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(NoContent());
        }
示例#5
0
        public async Task <ActionResult <BuildingDto> > PutSecretLair(int id, [FromBody] BuildingDto secretLair)
        {
            var updateSecretLair = await _context.Buildings
                                   .Include(p => p.Position)
                                   .FirstOrDefaultAsync(sd => sd.Id == id);

            if (updateSecretLair == null)
            {
                return(NotFound());
            }

            updateSecretLair.Title        = secretLair.Title;
            updateSecretLair.Icon         = secretLair.Icon;
            updateSecretLair.Feed         = secretLair.Feed;
            updateSecretLair.Position.Lat = secretLair.Position.Lat;
            updateSecretLair.Position.Lng = secretLair.Position.Lng;

            _context.Entry(updateSecretLair).State = EntityState.Modified;

            await _context.SaveChangesAsync();

            return(NoContent());
        }