2016-08-05 23:59:59 -04:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Threading.Tasks;
|
2017-03-08 21:45:08 -05:00
|
|
|
|
using Bit.Core.Models.Table;
|
2016-08-05 23:59:59 -04:00
|
|
|
|
using Bit.Core.Repositories;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bit.Core.Services
|
|
|
|
|
|
{
|
|
|
|
|
|
public class DeviceService : IDeviceService
|
|
|
|
|
|
{
|
|
|
|
|
|
private readonly IDeviceRepository _deviceRepository;
|
|
|
|
|
|
|
|
|
|
|
|
public DeviceService(
|
|
|
|
|
|
IDeviceRepository deviceRepository)
|
|
|
|
|
|
{
|
|
|
|
|
|
_deviceRepository = deviceRepository;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public async Task SaveAsync(Device device)
|
|
|
|
|
|
{
|
|
|
|
|
|
if(device.Id == default(Guid))
|
|
|
|
|
|
{
|
|
|
|
|
|
await _deviceRepository.CreateAsync(device);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
device.RevisionDate = DateTime.UtcNow;
|
|
|
|
|
|
await _deviceRepository.ReplaceAsync(device);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|