Beispiel #1
0
        public async Task <IActionResult> Create([Bind("userID,displayName,password,isAdmin")] User user)
        {
            if (ModelState.IsValid)
            {
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("roomID,roomName")] Room room)
        {
            if (ModelState.IsValid)
            {
                _context.Add(room);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(room));
        }
        public async Task <IActionResult> Create([Bind("sensorID,timestamp,servoSetting")] SensorLog sensorLog)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sensorLog);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["sensorID"] = new SelectList(_context.Sensor, "sensorID", "sensorID", sensorLog.sensorID);
            return(View(sensorLog));
        }
Beispiel #4
0
        public async Task <IActionResult> Create([Bind("sensorID,roomID,servoSetting")] Sensor sensor)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sensor);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["roomID"] = new SelectList(_context.Room, "roomID", "roomID", sensor.roomID);
            return(View(sensor));
        }
Beispiel #5
0
        public async Task <IActionResult> Create([Bind("sensorID,timestamp,humidity,CO2,temperature")] Models.Data data)
        {
            if (ModelState.IsValid)
            {
                _context.Add(data);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["sensorID"] = new SelectList(_context.Set <Sensor>(), "sensorID", "sensorID", data.sensorID);
            return(View(data));
        }
Beispiel #6
0
        public async Task <IActionResult> Create([Bind("userID,roomID")] RoomAccess roomAccess)
        {
            if (ModelState.IsValid)
            {
                _context.Add(roomAccess);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["roomID"] = new SelectList(_context.Room, "roomID", "roomID", roomAccess.roomID);
            ViewData["userID"] = new SelectList(_context.Set <User>(), "userID", "userID", roomAccess.userID);
            return(View(roomAccess));
        }