public async Task <m_device> CreateDevice(m_device device) { device.createdOn = DateTime.Now; device.isEnabled = true; var new_log = await _context.m_device.AddAsync(device); await _context.SaveChangesAsync(); return(new_log.Entity); }
// public async Task<IActionResult> GetAllTrkDos(){ // return Ok(await this.repo.GetAllTrkDos()); // } public async Task <IActionResult> device(m_device device) { if (await repo.GetDevice(device.DeviceID) != null) { return(BadRequest("device already exists")); } var created = await repo.CreateDevice(device); return(Ok(created)); }
public async Task <m_device> UpdateDevice(m_device device) { var result = await _context.m_device.FirstOrDefaultAsync(e => e.DeviceID == device.DeviceID); result.DeviceID = device.DeviceID; result.Name = device.Name; result.Purpose = device.Purpose; result.PuttoUse = device.PuttoUse; result.Battery = device.Battery; result.Healthy = device.Healthy; result.SoftwareVersion = device.SoftwareVersion; result.Vcc = device.Vcc; result.Lifespan = device.Lifespan; result.modifiedOn = DateTime.Now; result.modifiedBy = device.modifiedBy; result.isEnabled = device.isEnabled; await _context.SaveChangesAsync(); return(result); }
public async Task <IActionResult> deviceupdate(m_device device) { var created = await repo.UpdateDevice(device); return(Ok(created)); }