//Update The Booking public async Task <Devices.Domain.AggregatesModel.Device> UpdateAsync(Devices.Domain.AggregatesModel.Device device) { device.UpdatedDate = DateTime.Now; //_context.Bookings.Update(bookingOrder); await _context.SaveChangesAsync(); return(device); }
//Add the book public async Task <string> AddAsync(Devices.Domain.AggregatesModel.Device device) { device.CreatedDate = DateTime.Now; _context.Set <Devices.Domain.AggregatesModel.Device>().Add(device); await _context.SaveChangesAsync(); return(device.DeviceId); }
public async Task <string> Handle(RegisterDeviceCommand request, CancellationToken cancellationToken) { //Create Agreegate Root var deviceInfo = new Devices.Domain.AggregatesModel.Device(request.TenantId, request.Brand, request.Type, request.HardwareId , DeviceRegistrationState.Pending); //Create Integration Event var deviceAddIntegrationEvent = new DeviceRegistrationIntegrationEvent(deviceInfo.DeviceId); //Save the Data in local DB var deviceId = await _deviceContext.AddAsync(deviceInfo); //Publish Event to Service Bus Topic _eventBus.Publish(deviceAddIntegrationEvent); //Return Booking Ref return(deviceId); }