public async Task <EquipmentArea> UpdateEquipmentAreaAsync(EquipmentAreaView equipArea, CancellationToken cancellationToken) { if (equipArea == null) { throw new ArgumentNullException(nameof(equipArea)); } var dbEquipmentArea = await _context.EquipmentAreas .Where(eq => eq.AreaId == equipArea.AreaId && eq.EquipmentId == equipArea.EquipmentId) .SingleOrDefaultAsync(cancellationToken); dbEquipmentArea.Count = equipArea.Count; _context.Entry(dbEquipmentArea).State = EntityState.Modified; return(dbEquipmentArea); }
public async Task <EquipmentArea> AddEquipmentAreaAsync(EquipmentAreaView equipArea, CancellationToken cancellationToken) { if (equipArea == null) { throw new ArgumentNullException(nameof(equipArea)); } var dbEquipmentArea = new EquipmentArea { AreaId = equipArea.AreaId, EquipmentId = equipArea.EquipmentId, Count = equipArea.Count, CreatedAt = DateTime.UtcNow }; await _context.EquipmentAreas.AddAsync(dbEquipmentArea, cancellationToken); return(dbEquipmentArea); }