public async Task <IActionResult> PutNotificationFromDevice(int id, NotificationFromDevice notificationFromDevice)
        {
            if (id != notificationFromDevice.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <Device> CreateDevice(Device device)
        {
            var insertedDevice = await _context.Devices.AddAsync(device);

            await _context.SaveChangesAsync();

            return(insertedDevice.Entity);
        }
Пример #3
0
        public async Task <T> Add(T Item)
        {
            var result = await _dbContext.AddAsync(Item);

            await _dbContext.SaveChangesAsync();

            return(result.Entity);
        }
        public async Task <IActionResult> Create([Bind("ID,Type,Producer,Model,ReliableUser,Price,Ticket")] Devices devices)
        {
            if (ModelState.IsValid)
            {
                _context.Add(devices);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(devices));
        }