コード例 #1
0
        public async Task <IActionResult> PutTasky([FromRoute] Guid id, [FromBody] Tasky tasky)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
コード例 #2
0
        public async Task <IActionResult> PutPaymentType([FromRoute] int id, [FromBody] PaymentType paymentType)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

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

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

            return(NoContent());
        }
コード例 #3
0
        public async Task <IActionResult> PutUsers(int id, Users users)
        {
            if (id != users.id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
コード例 #4
0
        public async Task HandleAsync(HeartBeatCommand command)
        {
            var heartbeat = new HeartBeat {
                DeviceId = command.DeviceId, CreatedAt = DateTime.UtcNow
            };
            await _ctx.AddAsync(heartbeat);

            await _ctx.SaveChangesAsync();

            var updateEvent = new DeviceStatusUpdatedEvent {
                DeviceId = command.DeviceId, LastSeenAt = heartbeat.CreatedAt
            };
            await _serviceBus.PublishEventAsync(updateEvent);

            _logger.LogInformation("Device {0} heartbeat registred at {1}.", heartbeat.DeviceId, heartbeat.CreatedAt);
        }