public async Task <IActionResult> PutMaintenanceItem(Guid id, MaintenanceItem maintenanceItem) { if (id != maintenanceItem.ItemId) { return(BadRequest()); } await maintenanceItemService.PutMaintenanceItem(maintenanceItem); try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!maintenanceItemService.MaintenanceItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutItem(Guid id, Item item) { if (id != item.Id) { return(BadRequest()); } _context.Entry(item).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!itemService.ItemExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PutMaintenance(Guid id, Maintenance maintenance) { if (id != maintenance.Id) { return(BadRequest()); } _context.Entry(maintenance).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!maintenanceService.MaintenanceExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task CheckStatus() { var today = DateTime.Now.Date; var schedules = await _context.Schedules.Where(s => s.MaintenanceDate < today && s.Status == Status.Pending).ToListAsync(); if (schedules.Count() > 0) { foreach (var schedule in schedules) { schedule.Status = Status.NotAccomplished; _context.Entry(schedule).State = EntityState.Modified; } try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } } }
public async Task <IActionResult> PutComputer(Guid id, Computer computer) { if (id != computer.Id) { return(BadRequest()); } _context.Entry(computer).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!computerService.ComputerExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <ActionResult <ItemComputer> > PostItemComputer(ItemComputer itemComputer) { await itemComputerService.PostItemComputer(itemComputer); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (itemComputerService.ItemComputerExists(itemComputer.ComputerId)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetItemComputers", new { computerId = itemComputer.ComputerId }, itemComputer)); }
public async Task <IActionResult> StatusAccomplished(UpdateStatus updateStatus) { var result = await scheduleService.StatusAccomplished(updateStatus); if (result == null) { return(NotFound()); } result.Status = Status.Accomplished; _context.Entry(result).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { throw; } return(NoContent()); }
public async Task PostMaintenance(Maintenance maintenance) { _context.Maintenances.Add(maintenance); await _context.SaveChangesAsync(); }
public async Task PostComputer(Computer computer) { _context.Computers.Add(computer); await _context.SaveChangesAsync(); }
public async Task PostItem(Item item) { _context.Items.Add(item); await _context.SaveChangesAsync(); }