public async Task <bool> DeleteShareEquipment(int equipmentId, int groupId) { try { EquipmentsToGroup etg = await _context.EquipmentsToGroup.FirstOrDefaultAsync(x => x.EquipmentId == equipmentId && x.GroupId == groupId); _context.EquipmentsToGroup.Remove(etg); await _context.SaveChangesAsync(); } catch (Exception ex) { throw ex; } return(true); }
public async Task <Equipments> ShareEquipment(ShareEquipmentDto euqipmentToShare) { // wysharowanie ekwipunku var eqToShare = await _context.Equipments.FirstOrDefaultAsync(x => x.Id == euqipmentToShare.EquipmentId); var eqShared = new EquipmentsToGroup() { EquipmentId = euqipmentToShare.EquipmentId, GroupId = euqipmentToShare.GroupId }; await _context.EquipmentsToGroup.AddAsync(eqShared); await _context.SaveChangesAsync(); return(eqToShare); }